Jump to content


Photo

Need help about more than 1 deletion


  • Please log in to reply
4 replies to this topic

#1 PakiGangsta

PakiGangsta
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 08 June 2006 - 12:40 AM

Alright i have this as my code and it only deletes only one and that is it.
$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();
}

Please help me.
The one and only KingBowser :).

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 08 June 2006 - 12:53 AM

1. This should be outside of the foreach loop.

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

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

~ D Kuang

#3 PakiGangsta

PakiGangsta
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 08 June 2006 - 01:00 AM

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--]
The one and only KingBowser :).

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 08 June 2006 - 01:01 AM

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.
~ D Kuang

#5 PakiGangsta

PakiGangsta
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 08 June 2006 - 01:10 AM

[!--quoteo(post=381231:date=Jun 7 2006, 08:01 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 7 2006, 08:01 PM) View Post[/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();

The one and only KingBowser :).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users