Page 1 of 1

My delete function doesn't work! (PM System)

Posted: Thu Jan 24, 2013 8:54 pm
by Shahlin
I'm done with the whole PM system. Only thing that's not working is the delete conversation feature. Here's my delete_conversation function :

[syntax=php]function delete_conversation($conversation_id){
$conversation_id = (int)$conversation_id;

$sql = "SELECT DISTINCT `conversation_deleted`
FROM `conversations_members`
WHERE `user_id` != {$_SESSION['user_id']}
AND `conversation_id` = {$conversation_id}";

$result = mysql_query($sql);

if(mysql_num_rows($result) === 1 && mysql_result($result, 0) == 1){
mysql_query("DELETE FROM `conversations` WHERE `conversation_id` = {$conversation_id}");
mysql_query("DELETE FROM `conversations_members` WHERE `conversation_id` = {$conversation_id}");
mysql_query("DELETE FROM `conversations_messages` WHERE `conversation_id` = {$conversation_id}");
} else {
$sql = "UPDATE `conversations_members`
SET `conversation_deleted` = 1
WHERE `conversation_id` = {$conversation_id}
AND `user_id` = {$_SESSION['user_id']}";

mysql_query($sql);

}
}[/syntax]

Re: My delete function doesn't work! (PM System)

Posted: Mon Jan 28, 2013 7:42 pm
by ExtremeGaming
[syntax=php]if(mysql_num_rows($result) === 1[/syntax]
One to many ='s here

Re: My delete function doesn't work! (PM System)

Posted: Tue Jan 29, 2013 7:54 am
by jacek
What is not working about it ? What does happen compared to what you expect ?