Page 1 of 1

Warning: mysql_num_rows(): [SOLVED]

Posted: Mon Jun 12, 2006 10:57 am
by tecktalkcm0391
I am getting the error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/public_html/add.php
with this:

Code: Select all

$owner = 'me';
$name = 'toast';
//All of the other vairables come from the previous part of the code
$get_total = @mysql_query("SELECT Name FROM `items` WHRER Owner='{$owner}' AND Name='{$name}' ");
		$total = mysql_num_rows($get_total);
		echo "<b> $name</b> have been added to <B>$owner</b> a total of<b> <u>$quantity times.</u></b> Now there are $total items of this type in $owner.<br>";
Any ideas why?

Posted: Mon Jun 12, 2006 11:07 am
by onion2k
Your SQL statement isn't working.

Code: Select all

$get_total = mysql_query("SELECT Name FROM `items` WHRER Owner='{$owner}' AND Name='{$name}' ") or die mysql_error();
When you're developing, never use the @ directive to remove errors. It'll just make you wonder where errors are arising. Add it in later if you really have to use it.

Posted: Mon Jun 12, 2006 11:11 am
by tecktalkcm0391
I changed it, and it still gives me the errors...

Posted: Mon Jun 12, 2006 11:14 am
by tecktalkcm0391
AGAIN. I didn't even look at my code thoughtly I dunno how I keep missing all of my errors!

Code: Select all

//The original was:
 mysql_query("SELECT Name FROM `items` WHRER Owner='{$owner}' AND Name='{$name}'
//But I mistyped WHERE, so now this works:
 mysql_query("SELECT Name FROM `items` WHERE Owner='{$owner}' AND Name='{$name}'