Bug #50056 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc
Submitted: 4 Jan 2010 15:02 Modified: 12 Feb 2010 7:44
Reporter: devang parikh Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Errors Severity:S1 (Critical)
Version:5.0.87 OS:Windows
Assigned to: CPU Architecture:Any
Tags: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc

[4 Jan 2010 15:02] devang parikh
Description:
Hi,

I have moved my website to the newer version of MySQL 5.0.87 from the older one which was 4.1.20.

Also,the newer PhpMyAdmin is 3.2.4 whereas the old one was 2.6.4

I get the following warning as

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/labexpre/public_html/w_show_categories.php on line 16.

Here's the code that shows the warning:

function getCategoriesArray($parent_id,$level=0){

	
	$categories = array();
	$ct = 0;
	
	$cquery = "select categories.categories_id,categories_description.categories_name from categories,categories_description ";
	$cquery .= "where categories.parent_id = $parent_id and categories.categories_id = categories_description.categories_id";

	$cresult = mysql_query($cquery);
	
	$px = $level * 20;
	
	if(mysql_num_rows($cresult)>0){
		while($r = mysql_fetch_array($cresult)){
		
			$categories_id = $r['categories_id'];
			
			if($parent_id>0) $categories_id = $parent_id."_".$categories_id;
						
			$categories_string = '<li style="margin-left:'.$px.'px">';
	

	
			$categories_string .= '<a href="';
		
			$categories_string .= 'products.php?cPath=' . $categories_id . '">';
		
			$categories_string .= $r['categories_name'];
		
			$categories_string .= '</a>';
		
			$categories_string .= '</li>';
			$categories_string .= "\n";
			
		
			$categories[$ct]['string'] = $categories_string;
			$categories[$ct]['subcategories'] = getCategoriesArray($categories_id,$level+1);
			
			$ct++;
		}
	} 
	return $categories;	

I have tried to use the following code but it did not solve the problem.

$cresult = mysql_query($cquery) or die('Query failed: ' . mysql_error() . "<br />\n$cquery");

How to repeat:
The code works fine on the older version(4.1.20) of MySQL but when I move it to the newer version(5.0.87),i get the warning message.
[4 Jan 2010 15:21] devang parikh
Need to resolve it immediately.
[4 Jan 2010 15:22] devang parikh
Need to resolve it immediately.
[12 Jan 2010 7:44] Sveta Smirnova
Thank you for the report.

> I have tried to use the following code but it did not solve the problem.

> $cresult = mysql_query($cquery) or die('Query failed: ' . mysql_error() . "<br
/>\n$cquery");

What mysql_error() outputs?
[13 Feb 2010 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".