Private message system PART 11 error
Posted: Thu Jun 21, 2012 8:58 am
function fetch_conversation_summery(){ $sql = "SELECT conversations.conversation_id, conversations.conversation_subject, MAX(conversations_messages.message_date) AS conversation_last_reply, MAX(conversations_messages.message_date) > conversations_members.conversation_last_view AS conversation_unread FROM conversations LEFT JOIN conversations_messages ON conversations.conversation_id = conversations_messages.conversation_id INNER JOIN conversations_members ON conversations.conversation_id = conversations_members.conversation_id WHERE conversations_members.user_id = {$_SESSION['user_id']} AND conversations_members.conversation_deleted = 0 GROUP BY conversations.conversation_id ORDER BY conversation_last_reply DESC"; $result = mysql_query($sql); $conversations = array(); while(($row = mysql_fetch_assoc($result)) !== FALSE){ $conversations[] = array( 'id' => $row['conversation_id'], 'subject' => $row['conversation_subject'], 'last_reply' => $row['conversation_last_reply'], 'unread_messages' => ($row['conversation_unread'] == 1) //it will =1 if it's true ); } return $conversations; } function create_conversation($user_ids, $subject, $body){ $subject = mysql_real_escape_string(htmlentities($subject)); $body = mysql_real_escape_string(htmlentities($body)); mysql_query("INSERT INTO conversations (conversation_subject) VALUE ('{$subject}')"); $conversation_id = mysql_insert_id(); $sql = "INSERT INTO conversations_messages (conversation_id, user_id, message_date, message_text) VALUES ({$conversation_id}, {$_SESSION['user_id']}, UNIX_TIMESTAMP(), '{$body}')"; mysql_query($sql); $values = array(); $user_ids[] = $_SESSION['user_id']; foreach($user_ids as $user_id){ $user_id = (int) $user_id; $values[] = "({$conversation_id}, {$user_id}, 0, 0)"; } $sql = "INSERT INTO conversations_members (conversation_id, user_id, conversation_last_view, conversation_deleted) VALUE " . implode(", ", $values); mysql_query($sql); } //check to see if the given user is a member of the given conversation. function validate_conversation_id($conversation_id){ $conversation_id = (int)$conversation_id; $sql = "SELECT COUNT(1) FROM conversations_members WHERE conversation_id = {$conversation_id} AND user_id = {$_SESSION['user_id']} AND conversation_deleted = 0"; $result = mysql_query($sql); return (mysql_result($result, 0) == 1); } function delete_conversation($conversation_id){ $conversation_id = (int)$conversation_id; $sql = "SELECT DISTINCT conversation_deleted FROM conversation_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 coversations_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); } }I check over and over and all code is correct, not sure why this happen.
ERROR:
( ! ) SCREAM: Error suppression ignored for
( ! ) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\betterPHP\private_message_system\core\inc\private_message.inc.php on line 97