Having Problems With PHP Update : Error?
First the error that I am getting :
"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 'option=2, emp_id=116702 WHERE id = 1' at line 1"
Second the code :
$emp = $_POST['emp'. $x];
$group = $_POST['group' .$x];
mysql_select_db($database_MINE_MySQL_Database, $MINE_MySQL_Database);
$rage = "UPDATE memorial_day SET option=$group, emp_id=$emp WHERE id = $x";
$result2 = mysql_query($rage, $MINE_MySQL_Database) or die(mysql_error());
Well as you see, the $x is a variable is one that changes.. it is anywhere from 1 to 30. And everything in my database is fine.. I see the name as memorial_day, I have check the columns names everything is good.
Now, what i have is a list of 30 slots of employee names and 3 option buttons. The select returns the emp id and the button option returns 1 2 or 3. I have a submit button that does a PHP self and I have an IF ISSET['submit'] that does work and I have checked with a echo statement.
full code ::
IF (isset($_POST['submit'])) {
FOR ($x = 1; $x <= 30; $x += 1 ) {
IF ($_POST['emp'. $x] == '' && $_POST['group' .$x] != '') {
ECHO "One or more Employee is missing.";
break;
} ELSEIF ($_POST['emp'. $x] != '' && $_POST['group' .$x] == '') {
ECHO "One or more Option is missing.";
break;
} ELSEIF ($_POST['emp'. $x] == '' && $_POST['group' .$x] == '') {
} ELSE {
}
$emp = $_POST['emp'. $x];
$group = $_POST['group' .$x];
mysql_select_db($database_MINE_MySQL_Database, $MINE_MySQL_Database);
$rage = "UPDATE memorial_day SET option=$group, emp_id=$emp WHERE id = $x";
$result2 = mysql_query($rage, $MINE_MySQL_Database) or die(mysql_error());
}
}
I have also tried moving the code inside the ELSE where it should go, but it still dosnt work.. I just want to know why its so frustrating!
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 ''memorial_day' SET 'option'=2, 'emp_id'=116702 WHERE 'id' = 1' at line 1
I put in the single quotes, and I am still having issues, I do think that was one of the issues though.
`id` int(11) NOT NULL auto_increment,
`emp_id` int(10) NOT NULL,
`1_option` int(1) NOT NULL,
That is my Database, I have now changed the option to 1_option.