Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    mysql_num_rows error

    Howdy - anyone see anything wrong with the following:

    PHP Code:
    function thread ($id) {

        global 
    $mes_id;
        global 
    $link;
        global 
    $html;
        global 
    $page;

        
    $result mysql_db_query(ysl"SELECT * FROM board WHERE id=$id");
        
    $row mysql_fetch_array($result);
        
    $id $row["id"];
        
    $parent $row["parent"];
        
    $thread $row["thread"];
        
    $name $row["name"];
        
    $email $row["email"];
        
    $subject $row["subject"];
        
    $message $row["message"];
        
    $ip $row["ip"];
        
    $dates $row["dates"];
        
    $staff $row["staff"];
        if (
    $staff == 1) { $staffname "(<font size=1 color=red>Managing Director</font>)"; }
        if (
    $staff == 2) { $staffname "(<font size=1 color=blue>Assistant Director</font>)"; }
        
    $name htmlspecialchars($name);
        
    $email htmlspecialchars($email);
        
    $subject htmlspecialchars($subject);
        
    $message htmlspecialchars($message);
        
    $datess date("F j, Y @ H:i"$dates);
        if(
    $parent 0) {
            
    $html .= "<ul>\n";
        }

        if(
    $id == $mes_id) {
            
    $html .= "<li><b>$subject</b> - <b>$name</b> - <i>$datess</i>\n";
        } else {
            if(
    $page>1) {
                
    $html .= "<li><a href=\"index.php?action=view&id=$id&page=$page\"><b>$subject</b></a> - <b>$name $staffname</b> - <i>$datess</i>\n";
            } else {
                
    $html .= "<li><a href=\"index.php?action=view&id=$id\"><b>$subject</b></a> - <b>$name $staffname</b> - <i>$datess</i>\n";
            }
        }

        
    $result mysql_db_query($dbname"SELECT id FROM board WHERE parent=$id ORDER BY dates DESC");
        
    $num mysql_num_rows($result);

        if(
    $num) {
            while(list(
    $id)=mysql_fetch_row($result)){
                
    thread($id);
            }
        }
        if(
    $parent 0) {
            
    $html .= "</ul>\n";
        }

    The num = mysql_num_rows($result) is coming up as an error - I get this: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in forum\index.php on line 221

    I have no doubt that it is probably the most basic of things - but I just cannot see it!

    Thanks in advance!

    Taylor.

  • #2
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Nevermind - for some reason it wasnt reading the value of $dbname, even though it is set at the start of the script and used numerous times through out. go figure.


  •  

    Posting Permissions

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