-1

I Have got Error in the Foreach loop in below Code,Can any one Help me to Fix the Error...

<form method="post" action="<?php  echo $_SERVER['PHP_SELF'];?>">

<?php



$dbc=mysqli_connect("localhost","root","","elvis_store") or die("Error Connecting to Mysql Database");

if(isset($_POST['submit'])){

foreach($_POST['todelete'] as delete_id){

$query="DELETE FROM email_list WHERE id=$delete_id";
mysqli_query($dbc,$query) or die("Error Querying Database");

}

echo "Customer(s) Removed";


}



$query="SELECT * FROM email_list";
$result=mysqli_query($dbc,$query)or die("Query Syntaxt is Incorrect");

while($row=mysqli_fetch_array($result)){

echo '<input type="checkbox" value="'.$row['id'].'" name="todelete[]"/>';
echo $row['first_name']." ".$row['last_name']." ".$row['email'];
echo "<br/>";




}



mysqli_close($dbc);




?>

<input type="submit" name"submit" value="Remove"/>




</body>
3
  • and error is ???? Don't make us guess
    – user557846
    Commented Jul 24, 2012 at 5:12
  • Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in C:\wamp\www\MakeMelvis.com\removeemail.php on line 19 Commented Jul 24, 2012 at 5:16
  • The name of the question is entirely out of context Commented Jul 24, 2012 at 6:17

1 Answer 1

1

I think the error must be due to this line:

foreach($_POST['todelete'] as delete_id){

Replace it with:

foreach($_POST['todelete'] as $delete_id){
1
  • 1
    +1. correct answer. the error message is indeed somewhat cryptic, but a decent IDE or editor should have highlighted the error.
    – Spudley
    Commented Jul 24, 2012 at 6:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.