Hey everyone,
I am getting the following error and I have spent hours looking at it and cannot figure out why!
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 'primary='doej2', secondary='1' WHERE id='2'' at line 1
Here is my code:
<?php
if (isset($_POST[Edit])){
$id = $_POST['id'];
$primary = $_POST['primary'];
$secondary = $_POST['secondary'];
$query = mysql_query("UPDATE eventcal SET primary='$primary', secondary='$secondary' WHERE id='$id'");
if (!$query) {
$_SESSION['alert'] = 'ERROR: ' . mysql_error();
}
}?>
And here is my table structure for eventcal table:
CREATE TABLE `eventcal` (
`id` int(10) unsigned NOT NULL auto_increment,
`region` tinyint(3) unsigned NOT NULL,
`primary` varchar(25) NOT NULL,
`secondary` tinyint(1) NOT NULL,
`eventDate` date NOT NULL,
PRIMARY KEY (`id`),
KEY `primary_2` (`primary`),
KEY `secondary` (`secondary`),
CONSTRAINT `eventcal_ibfk_1` FOREIGN KEY (`primary`) REFERENCES `users` (`username`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
Can anyone see what I'm missing? Thanks!