Jump to content

Need help about more than 1 deletion


PakiGangsta

Recommended Posts

Alright i have this as my code and it only deletes only one and that is it.
[code]
$box=$HTTP_POST_VARS['pm'];
$box_count=count($box);
foreach ($box as $dear) {
$del="DELETE FROM PM where ID='$dear'";
mysql_query($del) or die("Could not delete message");
echo "All selected private messages are deleted.";
include 'footer.php';
die();
}
[/code]
Please help me.
Link to comment
https://forums.phpfreaks.com/topic/11455-need-help-about-more-than-1-deletion/
Share on other sites

1. This should be outside of the foreach loop.

[code]echo "All selected private messages are deleted.";
include 'footer.php';
die();[/code]

Meaning after 1 message is deleted, the script aborts. Remove it from the loop.

2. If it deletes 1 message, it should be OK as soon as the die() is removed from the loop; but if that still doesn't work, check if your checkbox have the correct name (like pm[]) and that it gives you correctly an array.

3. $HTTP_POST_VARS is deprecated. Use $_POST instead
[!--quoteo(post=381231:date=Jun 7 2006, 08:01 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 7 2006, 08:01 PM) [snapback]381231[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The query shouldn't be executed more than once; there is no need to abort the execution of the script. Remember that die() will abort the entire script's execution.
[/quote] fixed it and thanks for all the help i knewed it was the problem in die();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.