FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Warning: mysql_num_rows():





DanielXP
I keep getting this error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ....../index.php on line 697

with this code

Code:
$get = mysql_query("SELECT * from pmessages where to = '$cybm[username]' order by id desc");
$nummessages = mysql_num_rows($get);


This is the DB format

Code:
CREATE TABLE `pmessages` (
`title` varchar(255) NOT NULL default 'Untitled Message',
`message` text NOT NULL,
`to` varchar(255) NOT NULL default '',
`from` varchar(255) NOT NULL default '',
`unread` varchar(255) NOT NULL default 'unread',
`date` date NOT NULL default '0000-00-00',
`id` int(15) NOT NULL auto_increment,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
DanielXP
I looked it all over and seach on google and can not find why its doing this
hexkid
DanielXP wrote:
I keep getting this error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ....../index.php on line 697

with this code

Code:
$get = mysql_query("SELECT * from pmessages where to = '$cybm[username]' order by id desc");
$nummessages = mysql_num_rows($get);


Try validating that $get is a valid resource
Code:
$get = mysql_query("SELECT * from pmessages where to = '$cybm[username]' order by id desc");
if ($get === false) {
  echo "There is an error in the query <tt>SELECT * from pmessages where to = '$cybm[username]' order by id desc</tt><br>";
  echo 'The error is: ', mysql_error();
  ### for simplicity sake I'll just stop the script now
  exit('<br><br>script stopped.');
}
$nummessages = mysql_num_rows($get);
DanielXP
Done it

Code:
$get = mysql_query("SELECT * FROM `pmessages` WHERE `to` = '$cybm[username]' order by id desc");
$nummessages = mysql_num_rows($get);


Thanks for ur help any way
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.