Having Problems With PHP Update : Error?

Technerd_Shawn

New member
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());
}
}
 
Back
Top