...

View Full Version : mysql_num_rows error



Taylor_1978
05-27-2004, 06:57 PM
Howdy - anyone see anything wrong with the following:



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! :thumbsup:

Taylor.

Taylor_1978
05-27-2004, 07:06 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum