I am trying to get a query to count the number of rows it finds, all i get is a warning: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp2\htdocs\birth\email2.php on line 58
function newMessages( $profile_id )
{
global $prefix;
$INITIATOR_FLAG = 1;
$INTERLOCUTOR_FLAG = 2;
$newMessageCountCache = array();
define('TBL_MAILBOX_CONVERSATION', $prefix.'mailbox_conversation');
define('TBL_MAILBOX_MESSAGE', $prefix.'mailbox_message');
$query = mysql_query("SELECT DISTINCT `c`.`conversation_id`
FROM `".TBL_MAILBOX_CONVERSATION."` AS `c`
LEFT JOIN `".TBL_MAILBOX_MESSAGE."` AS `m` ON (`c`.`conversation_id` = `m`.`conversation_id`)
WHERE (`initiator_id`=".$profile_id." OR `interlocutor_id`=".$profile_id.")
AND (`bm_deleted` IN(0,".$INTERLOCUTOR_FLAG.") AND `initiator_id`=".$profile_id." OR `bm_deleted` IN(0,".$INITIATOR_FLAG.") AND `interlocutor_id`=".$profile_id.")
AND (`bm_read` IN(0,".$INTERLOCUTOR_FLAG.") AND `initiator_id`=".$profile_id." OR `bm_read` IN(0,".$INITIATOR_FLAG.") AND `interlocutor_id`=".$profile_id.") AND `m`.`recipient_id`=".$profile_id."
");
$newMessageCountCache[$profile_id] = mysql_num_rows($query);
return $newMessageCountCache[$profile_id];
}
mysql_close($cxn);
$emails = newMessages( $profile_id );
echo $emails;
Line 58 is : $newMessageCountCache[$profile_id] = mysql_num_rows($query);
not sure what i am missing here. any help would greatly be appreciated i have dug sql is not my strong suit for sure.