refiking Posted January 20, 2008 Share Posted January 20, 2008 Heres what the script returns when ran: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/refiking/public_html/scripting/process.php on line 13 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/refiking/public_html/scripting/process.php on line 14 Here are line 12-14: $sl = mysql_query("SELECT * From tourney WHERE tid = '$tid' AND user = '$user'"); $fetch_em = mysql_fetch_array($sl); $numrows = mysql_num_rows($sl); Quote Link to comment https://forums.phpfreaks.com/topic/86923-solved-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 You failed to check your result before using it. The minimum syntax for a select should be... <?php $sql = "SELECT * From tourney WHERE tid = '$tid' AND user = '$user'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $fetch_em = mysql_fetch_array($result); } } else { die(mysql_error() . $sql); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86923-solved-not-a-valid-mysql-result-resource/#findComment-444387 Share on other sites More sharing options...
refiking Posted January 20, 2008 Author Share Posted January 20, 2008 OK Thanks. I found the problem. I don't have a user column in the table. How can I search all the columns in the table for $user ? Quote Link to comment https://forums.phpfreaks.com/topic/86923-solved-not-a-valid-mysql-result-resource/#findComment-444390 Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 Surely you know which field holds your usernames? Quote Link to comment https://forums.phpfreaks.com/topic/86923-solved-not-a-valid-mysql-result-resource/#findComment-444394 Share on other sites More sharing options...
refiking Posted January 20, 2008 Author Share Posted January 20, 2008 Actually, this is a tournament script. I am searching to see if the name is listed under this tournament id. There are 32 different players, so I'd like to search to see if their name is listed under one of the 32 columns for players. Is there a way to accomplish this? Quote Link to comment https://forums.phpfreaks.com/topic/86923-solved-not-a-valid-mysql-result-resource/#findComment-444398 Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 Sounds like a pretty poor db design, but yeah, you could execute. SELECT * FROM tbl WHERE '$user' IN(fld1,fld2,fld3,fld4); etc etc. Quote Link to comment https://forums.phpfreaks.com/topic/86923-solved-not-a-valid-mysql-result-resource/#findComment-444401 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.