View Full Version : Update Table Query

02-24-2007, 10:23 PM
I'm struggling to get the below query to work. Basically, I just want to set the field to 0 for all rows.

$sql = "UPDATE TABLE game_84 SET mission = \'0\' ";

02-24-2007, 10:49 PM
It would help if you gave us the error you are getting.

From what I can see you have one syntax error and one potential problem. The word "TABLE" doesn't belong-- the syntax is "update tablename set fieldname = value where condition".

The potential problem depends on the data type of your field "mission". If it is a char, or varchar, then you do indeed need the quotes as you have them. If it is an integer, then you should not include the quotes.

02-25-2007, 05:12 AM
...also in php, within double quotes, \' means literal backslash + literal single-quote.

$x = "\'"; // string of 2 characters: backslash + single quote

so MySQL will 'see' the backslashes which is not what you want.

With Fumigator's correction, this would probably have been fine:

$sql = "UPDATE game_84 SET mission = '0'";