Jump to content

Warning: mysql_fetch_assoc(): supplied argument is not a valid


bcode

Recommended Posts

        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'];

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.