bobleny Posted July 15, 2006 Share Posted July 15, 2006 Working on some pagination stuff and then all of the sudden I get this error:Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\All Users\Desktop\Keep\Data\Server\Tests\alignment\index.php on line 24I find this odd because it was working literally minutes ago!? What I didn’t change anything on that line how can this be?So anyone know what’s wrong?Here’s the code[code]<center><title>Sorry Attempt At Pagination</title><?php$database_hostname = "localhost";$database_username = "root";$database_password = "";if(!isset($_GET['number'])){ $number = "1";}else{ $number = $_GET['number'];}$max_results = 10;$from = (($page * $max_results) - $max_results); mysql_connect($database_hostname,$database_username,$database_password) or die("Unable to Connect to the MYSQL Database!");mysql_select_db("site") or die("Unable to Select the Database!");$query = "SELECT * FROM home ORDER BY id DESC LIMIT $from, $max_results" or die("Unable to Query!");$result = mysql_query($query);$num = mysql_numrows($result); # Line 24, btwmysql_close();for ($i = "0"; $i < $num; $i++){ $declare = mysql_result($result, $i, "declare"); $text = nl2br(mysql_result($result, $i, "text")); echo "<table border='1' cellspacing='0' cellpadding='3' bordercolor='#000000' width='75%'>\r\n"; echo "<caption>".$declare."</caption>\r\n"; echo "<tr>\r\n"; echo "<td>".$text."</td>\r\n"; echo "</tr>\r\n"; echo "</table>\r\n"; echo "<br />\r\n";}$total_pages = ceil($num / $max_results);echo "<table border='1' cellspacing='0' cellpadding='3' bordercolor='#000000' width='75%'>\r\n"; echo "<caption>Previous Updates:</caption>\r\n"; echo "<tr>\r\n"; echo "<td>"; for ($i = "1"; $i <= $total_pages; $i++){if (($number) == $i){echo "Page ".$i." ";}else{echo "<a href='".$_SERVER['PHP_SELF']."?number=".$i."'>Page ".$i."</a> ";}} echo "</td>\r\n"; echo "</tr>\r\n";echo "</table>\r\n";?></center>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 15, 2006 Share Posted July 15, 2006 Change this:[code]$query = "SELECT * FROM home ORDER BY id DESC LIMIT $from, $max_results" or die("Unable to Query!");$result = mysql_query($query);[/code]To this:[code]$query = "SELECT * FROM home ORDER BY id DESC LIMIT $from, $max_results";$result = mysql_query($query) or die("Error ". mysql_error(). " with query ". $query);[/code] Quote Link to comment Share on other sites More sharing options...
bobleny Posted July 15, 2006 Author Share Posted July 15, 2006 Hmmmm... Thats ugly!error:Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10, 10' at line 1 with query SELECT * FROM home ORDER BY id DESC LIMIT -10, 10"-10"!??!??!? what tha?whats 10*1-10? 0????Oh, Ok I figuered it out! Thanks That new error thingy narrowed down my little problem! Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.