Goldeneye Posted May 21, 2008 Share Posted May 21, 2008 MySQL version 5.0.22 So I am working on this notification system for my Forum. When I go to the PHP script that executes the query, and returns it in an array, I get the good old, "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource" error. After about 4 days of troubleshooting, I got thinking that maybe it was the Indexes.. could it be? Because I'm 99.9% certain I have the correct code on the scripting end. And yes, I did insert a piece of dummy data, but it's still not displaying. <?php CREATE TABLE `notifications` ( `noteid` mediumint(9) NOT NULL auto_increment, `type` int(2) NOT NULL, // forum message, article, link, privatemessage, etc. `time` int(11) NOT NULL, `userid` mediumint(9) NOT NULL, `username` varchar(100) NOT NULL, `reason` blob NOT NULL, `status` int(1) NOT NULL, // taken care of, or not taken care of. `getid1` int(20) NOT NULL, // board=id (From url) `getid2` int(20) NOT NULL, // topic=id (from url) `getid3` bigint(20) unsigned NOT NULL, // message=id (from url) PRIMARY KEY (`noteid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; ?> Speaking of which, I'm getting the same thing with my private messaging system as well.. I have a 'valid' piece of dummy data in the table, but it too returns the same error, and I'm 99.9% certain I have the correct query code for that as well. So can indexes prevent a successful query? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 21, 2008 Share Posted May 21, 2008 A mysql_query() either returns a result resource if the query executed (even if there are zero rows in the result set) or a FALSE value if the query failed. Some reasons a query would fail are - no connection to a database server, no database selected, a syntax error in your query... The error message means that the query failed but your code blindly attempted to access a non-existent result resource. To get mysql to tell you why the query failed you need to use the mysql_error() function in your error checking logic. There are examples of error checking in the php manual for the mysql_query() function - http://php.net/mysql_query Quote Link to comment 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.