Forum Moderators: coopster
Parse error: parse error in \insert-muliple-records.php on line 52
FORM
<form method="POST" action="">
<input type="checkbox" name="id[]" value="32">Article #32<br>
<input type="checkbox" name="id[]" value="38">Article #38<br>
<input type="checkbox" name="id[]" value="45">Article #45<br>
<input type="checkbox" name="id[]" value="59">Article #59<br>
<input type="hidden" name="referer" value="123">
<input name="action" type="Submit" id="action" value="Submit">
PHP Code :
<?
if($action = Submit){
foreach ($_POST['id']) as $id) {
$sql = "insert into keywords (id, referer) values ($id, '$referer')";
$result = mysql_query($sql ,$db);
}
}
?>
please help me how to solve this problem
foreach ($_POST['id']) as $id) {
You have too many parenthesis.
foreach ($_POST['id'] as $id) {
You should also check that the post array is not empty before using a foreach loop. Try running the code with no boxes selected and see what happens.
Also, this line isn`t right:
if($action = Submit){
Try simply:
if(isset($_POST['action'])){
dc