Page 1 of 1

mysql_num_rows warning

Posted: Tue Dec 30, 2003 5:47 pm
by d3ad1ysp0rk

Code: Select all

$rowsql = "SELECT * FROM `rants` WHERE 1";
$result = mysql_query($rowsql);
$rows = mysql_num_rows($result);
Can you see anything that would cause the above code to not work?
It's pretty simple, all I'm doing is getting the number of rows for my while loop later on.. :?

Posted: Tue Dec 30, 2003 6:28 pm
by Gen-ik
I don't think you need the 'where 1' bit in there... normally you would use that for something like "SELECT * FROM `table` WHERE `name`='bob'".

Just try using SELECT * FROM `rants` and see if that works.

Posted: Tue Dec 30, 2003 6:37 pm
by nigma
Whats not working with your code? Is $rows not being assigned the number of rows returned when $rowsql query is executed?

Posted: Tue Dec 30, 2003 7:36 pm
by d3ad1ysp0rk
nigma, it was giving me this:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/des404/public_html/xrants/index.php on line 19
thanks for your help gen-ik, but i realized it was an error in my connection to the db.. sry for wasting ur time :p