php - SELECT query "greater than" not working properly? -


i have function of code written on site display user messages:

function fetch_conversation_summery(){     $sql = "select                 `conversations`.`conversation_id`,                 `conversations`.`conversation_subject`,                 max(`conversations_messages`.`message_date`) `conversation_last_reply`                 max(`conversations_messages`.`message_date`) > `conversations_members`.`conversation_last_view` `conversation_unread`             `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`             `conversations_members`.`userid` = {$_session['userid']}             , `conversations_members`.`conversation_deleted` = 0             group `conversations`.`conversation_id`             order `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; } 

although when try , use on correct page, issues error :

mysql_fetch_assoc() expects parameter 1 resource, boolean given in... 

i located problem within query, in line:

max(`conversations_messages`.`message_date`) > `conversations_members`.`conversation_last_view` `conversation_unread` 

although there seems nothing can see wrong it, of table names correct , still giving error? have ideas might causing this?

p.s code works fine without max line mentioned error located.

you missing comma after line:

max(`conversations_messages`.`message_date`) `conversation_last_reply` 

should be:

max(`conversations_messages`.`message_date`) `conversation_last_reply`, 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -