Warning: mysql_num_rows(): [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Warning: mysql_num_rows(): [SOLVED]

Post 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?
Last edited by tecktalkcm0391 on Mon Jun 12, 2006 11:14 am, edited 1 time in total.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

I changed it, and it still gives me the errors...
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post 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}'
Post Reply