Sign in to follow this  

MySQL Update Unknown Query in WHERE Clause

Recommended Posts

generalt    0

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?

Share this post


Link to post
Share on other sites
Nefarious Trigger    6,986

$qu = "UPDATE xcodes SET status = 1 WHERE codes = '$code'";

Share this post


Link to post
Share on other sites
generalt    0

Wow. I could have sworn I tried that.

 

Thanks!

Share this post


Link to post
Share on other sites
Nefarious Trigger    6,986

It's always the simplest things we overlook. Now, next, within your PHP, use the PDO library and turn that into a stored procedure and pass it parameters :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.