Page 1 of 1

i have an error

Posted: Sat Apr 07, 2007 11:11 am
by zyklon
mysql_num_rows(): supplied argument is not a valid MySQL result resource is the error, the line and the supplied argument are the following 2 lines:

Code: Select all

$result = mysql_query("SELECT * FROM events WHERE usertoid='$userd[id]'");
if(mysql_num_rows($result)) {

Posted: Sat Apr 07, 2007 11:13 am
by nickvd
I hope you don't expect us to fix your car if you only bring us the hood...

Posted: Sat Apr 07, 2007 11:15 am
by zyklon
wut else would you like to know?? the connection to the db is up, it is accessing real things in the db.... that was line 40, and 39, the error places...

Posted: Sat Apr 07, 2007 11:22 am
by nickvd
Echo the query. I'll bet that it doesn't look like what you expect...

also, the query should look like

Code: Select all

"SELECT * FROM `events` WHERE usertoid='{$userd['id']}'";
or

Code: Select all

'SELECT * FROM `events` WHERE usertoid="' . $userd['id'] . '"';
Adding error checking is also good...

for debugging you can use 'or die', but use proper error reporting on the production server

Code: Select all

$result = mysql_query(query) or die('Mysql Error: ' . mysql_error());

Posted: Sat Apr 07, 2007 11:25 am
by Oren
Unless 'id' is a constant, but I bet it isn't. If it is then I'll never code PHP again :P

Posted: Sat Apr 07, 2007 11:25 am
by zyklon
its workeed for me b4 the other way... but i'll give both a try


edit:i pugged the 1st one in and it worked


thank you.

Posted: Sun Apr 08, 2007 3:21 pm
by RobertGonzalez
You may want to search the PHP manual for array handling, strings and concatenation.