cerberus478 Posted April 14, 2014 Share Posted April 14, 2014 Hi I know this is probably a stupid question but I have this error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /var/www/vhosts/server.com/httpdocs/cms/classes/Page.php on line 2785 Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/server.com/httpdocs/cms/classes/Page.php on line 2787 On line 2785 is $combineArr = mysql_num_rows($query); On line 2787 while( $result1 = mysql_fetch_object($query) ){ This is the entire code function putGrid($pageid){ global $_GRID_FRAMES_TABLE, $_GRID_TABLE, $_GRID_CROSS_GRID_FRAMES_TABLE, $_GRID_CROSS_PAGES_TABLE, $_HTTP_ADDRESS; $i=0; $cpt = 1; $str = ''; $whichCount = 1; $query = mysql_query("SELECT * FROM $_GRID_TABLE WHERE id_page='$pageid'"); //return mysql_num_rows($query) or mysql_error(); //return $query; $combineArr = mysql_num_rows($query); while( $result1 = mysql_fetch_object($query) ){ if($whichCount == 1){ $gridClass="grid-active"; $style = "position: absolute; left:0%; top:0; width:100%;"; }else{ $gridClass="grid-inactive"; $style = "position: absolute; left:-100%; top:0; width:100%;"; } if($whichCount == 1){ $str.='<div id="grid-slide'.$i.'" class="grid-slide '.$gridClass.'" style="'.$style.'">'; $str.= '<div class="grid-slide-inner">'; $str.= '<div class="grid-banner-content grid-banner-left">'; $str.= '<div class="grid-banner-header">'; $str.= '</div>'; $str.= '<div class="grid-banner-copy">'; $str.= '<ul id="gallery">'; } $str.= '<li>'; $str.= '<img src="'.$_HTTP_ADDRESS.'products_images/'.$result->image.'">'; $str.= '<span>'; $str.= '<h3>'.$result->name.'</h3>'; $str.= $result->description; $str.= '</span>'; $str.= '</li>'; if($whichCount % 9 == 0 && $whichCount < $combineArr){ $i++; $str.= '</ul>'; $str.= '</div>'; $str.= '</div>'; $str.= '</div>'; $str.='</div>'; $str.='<div id="grid-slide'.$i.'" class="grid-slide '.$gridClass.'" style="'.$style.'">'; $str.= '<div class="grid-slide-inner">'; $str.= '<div class="grid-banner-content grid-banner-left">'; $str.= '<div class="grid-banner-header">'; $str.= '</div>'; $str.= '<div class="grid-banner-copy">'; $str.= '<ul id="gallery">'; } if($whichCount == $combineArr){ $str.= '</ul>'; $str.= '</div>'; $str.= '</div>'; $str.= '</div>'; $str.='</div>'; } $whichCount++; $cpt++; } return $str; } Link to comment https://forums.phpfreaks.com/topic/287751-warning-mysql_num_rows-expects-parameter-1-to-be-resource-boolean-given-in/ Share on other sites More sharing options...
requinix Posted April 14, 2014 Share Posted April 14, 2014 FAQ #6. mysql* expects parameter 1 to be resource, boolean given Link to comment https://forums.phpfreaks.com/topic/287751-warning-mysql_num_rows-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1476045 Share on other sites More sharing options...
cerberus478 Posted April 14, 2014 Author Share Posted April 14, 2014 I tried to get the errors to show but they aren't showing Link to comment https://forums.phpfreaks.com/topic/287751-warning-mysql_num_rows-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1476046 Share on other sites More sharing options...
adam_bray Posted April 14, 2014 Share Posted April 14, 2014 The best place to start is with the query. Change $query = mysql_query("SELECT * FROM $_GRID_TABLE WHERE id_page='$pageid'"); To $query = mysql_query("SELECT * FROM $_GRID_TABLE WHERE id_page='$pageid'")or die('Error:' . mysql_error() . "SELECT * FROM $_GRID_TABLE WHERE id_page='$pageid'"); That should show any errors & show you the exact query that's being run. I'd suggest removing the crappy error code and replacing it with something a bit nicer once the error is sorted. Link to comment https://forums.phpfreaks.com/topic/287751-warning-mysql_num_rows-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1476052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.