Cant figure out what the problem is!
$msgs = mysql_num_rows(mysql_query("SELECT * FROM messages WHERE recipient = $userID AND read = 0"));
echo $msgs;
The above code works if I remove "and read =0". But if not i get:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in left_menu.php on line 16. I have a field in the table called read (tinyint 1,defualt 0)
CREATE TABLE IF NOT EXISTS `messages` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`sender` int(10) unsigned NOT NULL DEFAULT '0',
`recipient` int(10) unsigned NOT NULL DEFAULT '0',
`subject` varchar(255) CHARACTER SET utf8 NOT NULL,
`message` text CHARACTER SET utf8,
`date` int(10) unsigned NOT NULL DEFAULT '0',
`read` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
)
INSERT INTO `messages` (`id`, `sender`, `recipient`, `subject`, `message`, `date`, `read`) VALUES
(1, 47, 13, 'Hello!', 'TEST!', 1228326055, 0),
(2, 536, 13, 'blblabla', 'yeah', 1248506708, 0);
Whats the problem?