Jump to content

Recommended Posts

Im trying to update a row using php in my MYSQL db, but it keeps failing. the code is this:

 

            $query = "UPDATE lotto SET state='1', winner='$user' ". "WHERE row = '$row' AND WHERE column = '$col' LIMIT 1"; //update the grid to clicked.
            mysql_query($query) or die(mysql_error());

 

ive tried taking away the second 'WHERE'. but no joy.

 

the error is:

 

"...right syntax to use near 'AND WHERE column = 29 LIMIT 1' at line 1"

Link to comment
https://forums.phpfreaks.com/topic/131802-query-errors/
Share on other sites

$query = "UPDATE lotto SET state='1', winner='".mysql_real_escape_string($user)."' WHERE row='".mysql_real_escape_string($row)."' AND column = '".mysql_real_escape_string($col)."' LIMIT 1"; 

 

Check your variables contain the correct data.

 

 

Link to comment
https://forums.phpfreaks.com/topic/131802-query-errors/#findComment-684683
Share on other sites

I believe your issue is that "column" is a mysql reserved word.  If that's the name of your column, put backticks around it like so:

 

`column`

 

better yet, change your column name to something other than a reserved word, as that's bad programming practice.

 

edit: PFM beat me to it :P

Link to comment
https://forums.phpfreaks.com/topic/131802-query-errors/#findComment-684690
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.