Hazzard Hazzard - 6 months ago 39
MySQL Question

MySQL Table Update Error

I'm almost sorry to ask this question but I'm drawing a complete blank. I'm getting the following error:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE number='7'' at line 1"

It seems whenever I try to use just an integer in the following code, I get the syntax error;

$go = mysql_query("UPDATE $db1 SET count='$t1c', WHERE number='$input2'") or die(mysql_error());

As you can see the page gets the value, that's not the issue.. it just doesn't seem to like the WHERE = 7 part. I've tried with and without the quote marks, I've tried changing that column in the table from a int to a varchar. Still get the same thing yet the code BEFORE this piece that runs:

$check1 = mysql_query("SELECT * FROM $db1 WHERE number='$input2'");

Run's absolutely fine. It finds the value where number equals $input2...

Can someone help me PLEASE? I'm drawing a complete blank here :/


Remove the , in the query:

mysql_query("UPDATE $db1 SET count='$t1c' WHERE number='$input2'");