RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Another mysql_num_rows(): error

Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 345
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Another mysql_num_rows(): error

  #2  
Jun 16th, 2005
This may seem too obvious, but the problem is that $result is not a valid MySQL resource. So why is that? Since your other queries work, we have to assume your connection is good. So the almost sure candidate is your query. Something is wrong with your query. Try changing your code to this:

[PHP]
if (!$result = mysql_query($query)) {
die(mysql_error());
}
$num_result = mysql_num_rows($result);
[/PHP]
This should print an error message that indicates what is wrong with the query.

Refer to http://us3.php.net/manual/en/function.mysql-error.php

Another thing I like to do when I'm having trouble with a query is run it directly against the database rather than in a PHP page. Do you have access to run the query directly against the database? For example, command line or phpMyAdmin? These tools give you nice feedback telling you what's wrong.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:03 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC