-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 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){
Sign up to request clarification or add additional context in comments.

1 Comment

+1. correct answer. the error message is indeed somewhat cryptic, but a decent IDE or editor should have highlighted the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.