[PHP] Back again with query problems and row problems
Okay I'm back guys...not sure what happened it was working..now it's all hung up... Here are the errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php on line 464 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php on line 488 Here is the full code snippet: ?php // Check if page is set to show allif(isset($_GET['show']) $_GET['show'] == 'all'){ unset($_SESSION['results']); unset($_SESSION['searchname']); unset($_SESSION['address']); } // Check if there was an empty search sent if(isset($_SESSION['noVarsSent'])){ echo pbNo values were submitted for the search./b/p; // Unset it so a reload of page doesn't redisplay the error unset($_SESSION['noVarsSent']); // unset($_SESSION['results']);} // Check if full list of restaurants has been created and stored yet// Store full results in $_SESSION to limit database hits if(!isset($_SESSION['fullRestaurantList'])) { // List not grabbed yet, so run query and store in $_SESSION //check for rangeif (!(isset($rangenum))) { $rangenum = 1; } // Grab all restaurants in alphabetical order $sql = SELECT ID, name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY name;; $result = mysql_query($sql); //trying to grab it by ranges from the db? $rows = mysql_num_rows($sql); $page_rows = 100; $last_row = ceil($rows/$page_rows); if ($rangenum 1){ $rangenum = 1; } elseif ($rangenum $last_row) { $rangenum = $last_row; } //This sets the range to display in our query $max = 'limit ' .($rangenum - 1) * $page_rows .',' .$page_rows; // Process all results into $_SESSION array $position = 1; while ($row = mysql_fetch_array($result)) { $_SESSION['fullRestaurantList'][$position] = $row; $position++; }
Re: [PHP] Back again with query problems and row problems
Miller, Terion wrote: Okay I'm back guys...not sure what happened it was working..now it's all hung up... Here are the errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php on line 464 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php on line 488 Here is the full code snippet: ?php // Check if page is set to show all if(isset($_GET['show']) $_GET['show'] == 'all') { unset($_SESSION['results']); unset($_SESSION['searchname']); unset($_SESSION['address']); } // Check if there was an empty search sent if(isset($_SESSION['noVarsSent'])){ echo pbNo values were submitted for the search./b/p; // Unset it so a reload of page doesn't redisplay the error unset($_SESSION['noVarsSent']); // unset($_SESSION['results']);} // Check if full list of restaurants has been created and stored yet// Store full results in $_SESSION to limit database hits if(!isset($_SESSION['fullRestaurantList'])) { // List not grabbed yet, so run query and store in $_SESSION //check for rangeif (!(isset($rangenum))) { $rangenum = 1; } // Grab all restaurants in alphabetical order $sql = SELECT ID, name, address, inDate, inType, notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY name;; $result = mysql_query($sql); //trying to grab it by ranges from the db? $rows = mysql_num_rows($sql); $page_rows = 100; $last_row = ceil($rows/$page_rows); if ($rangenum 1){ $rangenum = 1; } elseif ($rangenum $last_row) { $rangenum = $last_row; } //This sets the range to display in our query $max = 'limit ' .($rangenum - 1) * $page_rows .',' .$page_rows; // Process all results into $_SESSION array $position = 1; while ($row = mysql_fetch_array($result)) { $_SESSION['fullRestaurantList'][$position] = $row; $position++; }