Jump to content

Can indexes prevent a query from properly executing?


Goldeneye

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.