Jump to content

Archived

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

PakiGangsta

Need help about more than 1 deletion

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
so shoul i take out the die cause wouldnt that stop the query to do it again or no

[!--fonto:Times New Roman--][span style=\"font-family:Times New Roman\"][!--/fonto--] fixed it :) thanks :D[!--fontc--][/span][!--/fontc--]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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();

Share this post


Link to post
Share on other sites

×

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.