I’m trying to select data from a certain row in a my sql db. This is the code im using:
mysql_connect($hostname,$username,$password) or die('connection error '.mysql_error()); mysql_select_db($dbname) or die('selection error '.mysql_error());
$select = mysql_query("SELECT FROM WordPress_theme_customers WHERE ". "GDI_Username = '$sponsor_GDI_id' AND Unique_id = '$sponsor_refference'");
while($check = mysql_fetch_array($select)) {
$sponsor_email = $check["Email"];
$sponsor = $check["GDI_Username"];
$sponsor_first_nme = $check["First_Name"];
$sponsor_second_nme = $check["Last_Name"];
$sponsor_domain = $check["GDI_Domain"];
$unq_id = $check["Unique_id"];
}
I keep getting this error:
“Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /SC/sponsor.php on line 10”
line 10 is: while($check = mysql_fetch_array($select)) {
I’ve made sure the db info is correct including the table name, still nothing.
thanks
Your query has a syntax error, causing
msyql_query()to return a boolean FALSE, not a result handle. Try doing:Putting the query into its own variable lets you examine it separately, and the
or die(...)will tell you exactly why the query failed.The syntax error itself is here:
you are not specifying any fields to retrieve. At minimum, it should be: