SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ID isnt showing up...

    ok ive got this functions in an include file:

    PHP Code:
    // comments()

    function comments() {

    $result mysql_query("SELECT * FROM comments WHERE entry = '$id'"); 
    $number mysql_num_rows($result);

    if (
    $number == "0") {
    echo (
    "<a href=comment.php?action=add&id=$id>Add Comment</a>");
    }

    elseif (
    $number == "1") {
    echo (
    "<a href=comment.php?id=$row[id]>1 comment | <a href=comment.php?action=add&id=$id>Add Comment</a>");
    }

    else {
    echo (
    "<a href=comment.php?id=$row[id]>$number comments | <a href=comment.php?action=add&id=$id>Add Comment</a>");
    }


    and ive got this piece of code in a script:

    PHP Code:
    // list entries

    $result mysql_query("SELECT * FROM entries ORDER BY id DESC LIMIT 10"); 
    while ( 
    $row mysql_fetch_array($result) ) { 

    $id $row[id];

    echo (
    "
        <table width=500 border=1 cellspacing=0 cellpadding=3 bordercolor=#000000>
            <tr> 
              <td bgcolor=#000000>
            <table width=100% border=0 cellspacing=0 cellpadding=0>
            <tr>
            <td></td>
            <td>
            <div align=right><font color=#FFFFFF>[ 
    $row[date] | $row[time] ]</font></div>
            </td>
            </tr>
            </table>
            <div></div>
              </td>
            </tr>
            <tr>
              <td bgcolor=#FFFFFF>
            <table width=100% border=0 cellspacing=1 cellpadding=1>
            <tr>
            <td>
    $row[entry]</td>
            </tr>
            <tr>
            <td>
            <div align=right>
    "
    );

    comments();

    echo(
    "
        </div>
            </td>
            </tr>
            </table>
              </td>
            </tr>
          </table>
        <br>
    "
    ); 


    but for some reason when i goto click on one of the links to add a comment the URL is http://www.cheeseblind.f2s.com/cheeseblind/comment.php?action=add&id= but it should have the id number on the end but it doesnt.

    Anyone know why?
    hmm...

  2. #2
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in your function $id isnt declared....

    you will either have to declare the fucntion like so


    PHP Code:
    function commments($id)
    {
    // whatever
    }


    // and then to use it in the program call it by doing...

    comments($id); 


    or delcare the function like this


    PHP Code:
    function commments()
    {
        global 
    $id;
    // whatever

    have to be careful of the scope of the variables

  3. #3
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thx alot ill try that when i get back
    hmm...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •