Jump to content

delete query doesnt work any help?


jamesxg1

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

 

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.