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
zyklon
Forum Commoner
Posts: 49 Joined: Mon Jul 31, 2006 7:14 pm
Location: MA, USA
Post
by zyklon » Sat Apr 07, 2007 11:11 am
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)) {
nickvd
DevNet Resident
Posts: 1027 Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:
Post
by nickvd » Sat Apr 07, 2007 11:13 am
I hope you don't expect us to fix your car if you only bring us the hood...
zyklon
Forum Commoner
Posts: 49 Joined: Mon Jul 31, 2006 7:14 pm
Location: MA, USA
Post
by zyklon » Sat Apr 07, 2007 11:15 am
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...
nickvd
DevNet Resident
Posts: 1027 Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:
Post
by nickvd » Sat Apr 07, 2007 11:22 am
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());
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sat Apr 07, 2007 11:25 am
Unless 'id' is a constant, but I bet it isn't. If it is then I'll never code PHP again
zyklon
Forum Commoner
Posts: 49 Joined: Mon Jul 31, 2006 7:14 pm
Location: MA, USA
Post
by zyklon » Sat Apr 07, 2007 11:25 am
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.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Sun Apr 08, 2007 3:21 pm
You may want to search the PHP manual for array handling, strings and concatenation.