bcode Posted January 15, 2010 Share Posted January 15, 2010 I can't get this to work I don't know what is wrong I have checked the table names and checked everything with print_r and the Mysql statement is printing right but to no avail. $names = explode(" ",$searchTerm); $datauser = "SELECT * "; $datauser .= "FROM users "; $datauser .= "WHERE firstName = $names[0] AND lastName = $names[1] "; $resultuser = mysql_query($datauser); $listuser = mysql_fetch_assoc($resultuser); $contractUser = $listuser['contract']; Quote Link to comment https://forums.phpfreaks.com/topic/188617-warning-mysql_fetch_assoc-supplied-argument-is-not-a-valid/ Share on other sites More sharing options...
fareedreg Posted January 15, 2010 Share Posted January 15, 2010 check is the table empty? Quote Link to comment https://forums.phpfreaks.com/topic/188617-warning-mysql_fetch_assoc-supplied-argument-is-not-a-valid/#findComment-995797 Share on other sites More sharing options...
PFMaBiSmAd Posted January 15, 2010 Share Posted January 15, 2010 Empty tables and queries that return zero rows DON'T cause mysql_ function errors. Your query failed to execute due to an error. In just looking at it, you need some single-quotes around '$names[0]' and '$names[1]' in the query to make those values string data instead of column names. Quote Link to comment https://forums.phpfreaks.com/topic/188617-warning-mysql_fetch_assoc-supplied-argument-is-not-a-valid/#findComment-995801 Share on other sites More sharing options...
bcode Posted January 15, 2010 Author Share Posted January 15, 2010 Thank you for the single quotes I can't believe that was what I was missing I was pulling my hair out over this. Quote Link to comment https://forums.phpfreaks.com/topic/188617-warning-mysql_fetch_assoc-supplied-argument-is-not-a-valid/#findComment-995817 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.