Jump to content

Recommended Posts

yes, but what is being assigned, check that you're getting the right number from your query

 

if i print the var ($pm_id) it shows me the correct id's wich makes me belive that it could be the checkbox that is causing the problem just a guess thoe :S

 

anyone have any ideas ?

try

<?php session_start(); 

require("../db/db.php"); //include database file
require("../db/config.php"); //include configuration file
require("../db/util.php");
require("../db/settings.php");

isloggedin();
accessneeded("C");



$user = $_SESSION['username'];

//We do not have a user check on this page, because it seems silly to, you just send data to this page then it directs you right back to inbox

//We need to get the total number of private messages the user has
$sql = mysql_query ("SELECT pm_count FROM users WHERE username='$user'");
$row = mysql_fetch_array ($sql);
$pm_count = $row['pm_count'];
foreach ($_POST['pms'] as $pm_id){           
   //Delete the PM from the database
   mysql_query("DELETE FROM `messages` WHERE `messages`.`id` = '$pm_id' AND reciever='$user' LIMIT 1");
   
   //Subtract a private message from the counter! YAY!
   $pm_count = $pm_count - mysql_affected_rows();
}  
   //Now update the users message count with the new value
   mysql_query("UPDATE users SET pm_count='$pm_count' WHERE username='$user'");
   
header("Location:inbox.php");
exit;
?> 

hiya i tryed it and i got this error

 

 

 

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\messages\delete.php on line 21

 

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\messages\delete.php:21) in C:\xampp\htdocs\messages\delete.php on line 31

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.