I am creating a pm system. I am creating it using 2 files. compose.php (To send PM's) and inbox.php (Where they will read their PMs.
compose.php works great. I can send messages easily.
I have a problem with inbox.php I am trying to run a script that will count a user's message that are unread so he can have a message saying: You have # new messages. If he doesn't have any new messages it will say: You have no new messages.
I get this error (please view the image):
http://img117.imageshack.us/img117/3917/inboxerror5ic.gif
Here is my code:
<?php
$name=$exist[1];
$unreadcount=mysql_query("SELECT name, read FROM phpqa_pm WHERE name='$name' AND read='no'");
$unread=mysql_num_rows($unreadcount);
echo "You have ".$unread." new messages!";
if (mysql_num_rows($unreadcount) == 0) {
echo "You have no new messages in your inbox!";
}else{
?>
Line 7= $unread=mysql_num_rows($unreadcount);
Line 10=if (mysql_num_rows($unreadcount) == 0) {
Thanks in advance.
If you would like the dump of phpqa_pm here it is.
-phpqa_pm's Table Structure:
CREATE TABLE `phpqa_pm` (
`name` varchar(20) default NULL,
`from` varchar(20) default NULL,
`subject` varchar(20) default NULL,
`message` varchar(250) NOT NULL default '',
`date` varchar(25) NOT NULL default '',
`read` varchar(20) NOT NULL default 'no'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
--phpqa_pm's Dump:
INSERT INTO phpqa_pm(`name`,`from`,`subject`,`message`,`date`,`read`) VALUES ('Seb','Seb','TESTER','gasdfgsdfg','10th July 2006 - 03:23 PM','no')
INSERT INTO phpqa_pm(`name`,`from`,`subject`,`message`,`date`,`read`) VALUES ('Seb','Seb','TESTER','gasdfgsdfg','10th July 2006 - 03:23 PM','no')
INSERT INTO phpqa_pm(`name`,`from`,`subject`,`message`,`date`,`read`) VALUES ('Seb','Seb','TESTING2','YO DUDE!!!','10th July 2006 - 01:31 AM','no')