Warning: mysql_num_rows(): supplied argument is not a valid MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kmacc
    New Member
    • Apr 2010
    • 1

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL

    Hi,

    I'm getting this error on a page after changing server host, the error did not happen on my old host. I'm thinking it is to do with a new MySQL version and more strict coding. Can anyone help?

    Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/xxxx/public_html/propview.php on line 78

    Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in /home/xxxx/public_html/propview.php on line 170

    Here is my code:
    Code:
    /spit out listings for multiple properties
    	function makelisting($querystring, $link, $guidestring, $cur_page, $properties_per_page, $sort)
    		{
    		if ($sort == "") {$sort = "id DESC";}
    		$querystring = $querystring." ORDER BY $sort";
    		$result = mysql_query("$querystring;",$link);
    		$num_rows = mysql_num_rows($result);   /this is line 78
    
    		$page_num = $cur_page + 1;
    		
    		$total_num_page = ceil($num_rows/$properties_per_page);
    Code:
    	$limit_str = "LIMIT ". $cur_page * $properties_per_page .",$properties_per_page";
    		$query = "$querystring $limit_str";
    		
    		
    		$result = mysql_query("$query;",$link);
    		
    
    						
    			
    			while ($a_row = mysql_fetch_array ($result) )  / this is line 170
    				{
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    I wrote an article that explains the reason for this error, and how to fix it.
    You can find it here, in the PHP insights section.

    Comment

    Working...