Jump to content

query errors....


joecooper

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

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.