jamesxg1 Posted February 9, 2009 Author Share Posted February 9, 2009 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 ? Link to comment https://forums.phpfreaks.com/topic/144342-delete-query-doesnt-work-any-help/page/2/#findComment-758024 Share on other sites More sharing options...
sasa Posted February 9, 2009 Share Posted February 9, 2009 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; ?> Link to comment https://forums.phpfreaks.com/topic/144342-delete-query-doesnt-work-any-help/page/2/#findComment-758084 Share on other sites More sharing options...
jamesxg1 Posted February 9, 2009 Author Share Posted February 9, 2009 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 Link to comment https://forums.phpfreaks.com/topic/144342-delete-query-doesnt-work-any-help/page/2/#findComment-758090 Share on other sites More sharing options...
sasa Posted February 9, 2009 Share Posted February 9, 2009 are you change your inbox script? Link to comment https://forums.phpfreaks.com/topic/144342-delete-query-doesnt-work-any-help/page/2/#findComment-758098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.