I'm using php to run a basic update on a database but I'm getting SQL syntax errors and I can't for the life of me see what's wrong. The field in the db is called orders, it is set to int(8).I have tried changing it to smallint and varchar, have increased but no joy. I have also tried tinkering with the ' and " in the query. The code is as follows...
$query = "UPDATE gigs SET order='$order' WHERE gig_id='$id'";
if ($r = mysql_query($query) ) {
echo "<p>UPDATED:" . $row['year'] ." - " . $row['month'] . " - " . $row['day'] . " = $order</p>";
} else {
echo "<p>" . mysql_error() . "<br />$q</p>";
}
$order is year month and day values combined into one integer value, e.g. 12 apr 2013 = 20130412.
here are the error messages I get
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 'order='20040802' WHERE gig_id='10'' at line 1 UPDATE gigs SET order='20040802' WHERE gig_id='10'
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 'order='20040804' WHERE gig_id='11'' at line 1 UPDATE gigs SET order='20040804' WHERE gig_id='11'