• 0

MySQL Update Unknown Query in WHERE Clause


Question

I'm trying to run a query to update table xcodes. xcodes has two columns: codes and status. I want to update the status of the code contained in $code to 1.

 

$qu = "UPDATE xcodes SET status = 1 WHERE codes = $code";
$re = mysqli_query ($dbc, $qu) or trigger_error("Query: $qu\n<br/>MySQL Error: " . mysqli_error($dbc));

 

When I run the query, I get an error telling me that the code (in the variable $code) is an unknown column! The column is codes, not $code.

 

An error occurred on line 83: Query: UPDATE clickycodes SET status = 1 WHERE (codes = d24rg26p)
MySQL Error: Unknown column 'd24rg26p' in 'where clause'

 

I must have my syntax wrong. I've tried putting $code in brackets {$code} to no avail. What am I doing wrong?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

This topic is now closed to further replies.