pyrox Posted January 10, 2009 Share Posted January 10, 2009 why does this statement error Function Getmailcount($UserID) { $dbhost="?????"; $dbpass="????"; $dbuser="???"; $database="????"; mysql_connect($dbhost, $dbuser, $dbpass) or die("The site database appears to be down."); @mysql_select_db($database) or die( "Unable to select database"); $sqlmail= "SELECT * FROM messsages WHERE to = '$UserID' AND to_viewed = '0'"; $querymail= mysql_query($sqlmail); $checkmailcount = mysql_num_rows($querymail); Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/haxorwar/public_html/includes/mailcount.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/ Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 check to make sure there is no errors with the query: $sqlmail= "SELECT * FROM messsages WHERE to = '$UserID' AND to_viewed = '0'"; $querymail= mysql_query($sqlmail)or die mysql_error()); $checkmailcount = mysql_num_rows($querymail); Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733976 Share on other sites More sharing options...
pyrox Posted January 10, 2009 Author Share Posted January 10, 2009 yea i triple checked it and still it tells me that Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733981 Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 have you got populated rows in the table? Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733984 Share on other sites More sharing options...
pyrox Posted January 10, 2009 Author Share Posted January 10, 2009 yea well kinda let me try to use another table that i know works hold on oh btw heres my table if you wanna check it out CREATE TABLE IF NOT EXISTS `messages` ( `id` int(11) NOT NULL auto_increment, `title` varchar(255) default NULL, `message` text NOT NULL, `from` int(11) NOT NULL, `to` int(11) NOT NULL, `from_viewed` tinyint(1) NOT NULL default '0', `to_viewed` tinyint(1) NOT NULL default '0', `from_deleted` tinyint(1) NOT NULL default '0', `to_deleted` tinyint(1) NOT NULL default '0', `from_vdate` datetime default NULL, `to_vdate` datetime default NULL, `from_ddate` datetime default NULL, `to_ddate` datetime default NULL, `created` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=28 ; -- -- Dumping data for table `messages` -- INSERT INTO `messages` (`id`, `title`, `message`, `from`, `to`, `from_viewed`, `to_viewed`, `from_deleted`, `to_deleted`, `from_vdate`, `to_vdate`, `from_ddate`, `to_ddate`, `created`) VALUES (27, 'maybe', 'nope', 3, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, '2009-01-10 06:01:31'), (26, 'oh', 'damn', 3, 3, 0, 0, 0, 0, NULL, NULL, NULL, NULL, '2009-01-10 05:54:48'), (23, 'nope', 'no cookies for you', 3, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:42:37', NULL, '2009-01-10 05:43:17', '2009-01-10 05:41:25'), (24, 'test', 'test', 11, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:42:16', NULL, '2009-01-10 05:50:24', '2009-01-10 05:42:09'), (25, 'Re: test', '[quote]test[/quote]\r\n\r\ndid my quote work', 3, 11, 0, 1, 0, 1, NULL, '2009-01-10 05:43:43', NULL, '2009-01-10 05:50:37', '2009-01-10 05:42:32'), (22, 'hi', 'test?', 3, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:34:05', NULL, '2009-01-10 05:43:25', '2009-01-10 05:33:46'), (21, 'hey', 'whatsup', 0, 3, 0, 1, 0, 1, NULL, '2009-01-10 05:42:11', NULL, '2009-01-10 05:42:14', '2009-01-10 05:29:31'); Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733986 Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 This is very odd I have created your table and populated it and run this code: require('db.php'); $query = mysql_query("SELECT * FROM messsages"); $checkmailcount = mysql_num_rows($query); and I get the same error as you but if I change the table in the query it works fine?? Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733989 Share on other sites More sharing options...
pyrox Posted January 10, 2009 Author Share Posted January 10, 2009 yea i cant figure out why could it be becuase i have NULL amounts what if i used Mysql_Fetch_Array Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733990 Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 Got it working seems ENGINE=MyISAM is causing the error. I removed DEFAULT CHARSET=latin1 AUTO_INCREMENT=28 ; It now works fine. Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733994 Share on other sites More sharing options...
pyrox Posted January 10, 2009 Author Share Posted January 10, 2009 alright so what was your final code i completly ripped apart my code so i can try it Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-733997 Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 here's the table structure I used: CREATE TABLE IF NOT EXISTS `messages` ( `id` int(11) NOT NULL auto_increment, `title` varchar(255) default NULL, `message` text NOT NULL, `from` int(11) NOT NULL, `to` int(11) NOT NULL, `from_viewed` tinyint(1) NOT NULL default '0', `to_viewed` tinyint(1) NOT NULL default '0', `from_deleted` tinyint(1) NOT NULL default '0', `to_deleted` tinyint(1) NOT NULL default '0', `from_vdate` datetime default NULL, `to_vdate` datetime default NULL, `from_ddate` datetime default NULL, `to_ddate` datetime default NULL, `created` datetime NOT NULL, PRIMARY KEY (`id`) ); Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-734004 Share on other sites More sharing options...
pyrox Posted January 10, 2009 Author Share Posted January 10, 2009 fuck that fucked it all up somehow i had to remake my whole PM system good thing i had a backup so i cant play with my table any other ideas Quote Link to comment https://forums.phpfreaks.com/topic/140269-new-to-php-noob-question/#findComment-734047 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.