CagedApe Posted July 23, 2010 Share Posted July 23, 2010 I keep getting the error: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I can't see the problem in my code. Any ideas? $message = $_POST['message']; $senderid = $SESSION['SESS_MEMBER_ID']; $recipient = $_POST['recipient']; $q = mysql_query("SELECT * FROM members WHERE member_id = $senderid"); $row = mysql_fetch_array($q); ///error says this is the bad line $sender = $row['username']; Quote Link to comment https://forums.phpfreaks.com/topic/208724-mysql_fetch_array-problem/ Share on other sites More sharing options...
gizmola Posted July 23, 2010 Share Posted July 23, 2010 I see a couple possible issues, but one that jumps right out is that you have $senderid = $SESSION... and this should be $_SESSION Quote Link to comment https://forums.phpfreaks.com/topic/208724-mysql_fetch_array-problem/#findComment-1090459 Share on other sites More sharing options...
CagedApe Posted July 23, 2010 Author Share Posted July 23, 2010 I changed that but still get the same error. What else did you see that might be wrong? Quote Link to comment https://forums.phpfreaks.com/topic/208724-mysql_fetch_array-problem/#findComment-1090463 Share on other sites More sharing options...
PFMaBiSmAd Posted July 24, 2010 Share Posted July 24, 2010 The error is because your query failed due to an error. If you echo mysql_error(); on the next line after the line with your mysql_query() statement, it will tell you why. Quote Link to comment https://forums.phpfreaks.com/topic/208724-mysql_fetch_array-problem/#findComment-1090469 Share on other sites More sharing options...
gizmola Posted July 24, 2010 Share Posted July 24, 2010 Could be what PFMaBiSmAd said, and in general my comment is that you have no error checking. Going even further, you don't make a database connection prior to the query. I assumed that maybe you were already doing that somewhere else, as well as starting the session because without a session_start() and a valid session, even the fix I gave you will still be a problem. Quote Link to comment https://forums.phpfreaks.com/topic/208724-mysql_fetch_array-problem/#findComment-1090475 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.