Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-27-2004, 05:57 PM   PM User | #1
Taylor_1978
Regular Coder

 
Join Date: Jun 2003
Location: Australia
Posts: 528
Thanks: 8
Thanked 8 Times in 8 Posts
Taylor_1978 is on a distinguished road
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.
Taylor_1978 is offline   Reply With Quote
Old 05-27-2004, 06:06 PM   PM User | #2
Taylor_1978
Regular Coder

 
Join Date: Jun 2003
Location: Australia
Posts: 528
Thanks: 8
Thanked 8 Times in 8 Posts
Taylor_1978 is on a distinguished road
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.
Taylor_1978 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:57 PM.


Advertisement
Log in to turn off these ads.