I have a problem with my query on part 9 of the series. It dosn't return any value.
I have try to use the mysql_error function but dosn't give me back and value.
I have a error like Resource id #9, what does that mean?
Also i got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MAX.
Here is the code.
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),
);
}
return $conversations;
}
thanks