timmah1 Posted April 17, 2009 Share Posted April 17, 2009 Can anybody tell me why I'm getting this 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 This worked just fine, but now I"m getting an error. Could it be because nothing is in the database? <?php include('config.php'); if (!(isset($_GET['pagenum']))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM wishlist") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 10; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $data_p = mysql_query("SELECT * FROM wishlist $max") or die(mysql_error()); while($p = mysql_fetch_array( $data_p )) { $content = stripslashes($p['content']); $item = $p['item']; $site = $p['site']; $price = $p['price']; $photo = $p['photo']; $name = $p['name']; ?> <p class="text-content"> <table border="0" cellspacing="0" cellpadding="6" class="text"> <tr> <td align="left" valign="top"><span class="user_info"><strong><?=$name;?></strong> on <i>#<?=$item?></i></span></td> </tr> <tr> <td align="left" valign="top"><span class="posts"><img src="wish/<?=$photo;?>" width="100" class="photoID" align="left" /><?=nl2br($comment);?></span></td> </tr> </table> <?php } if ($pagenum == 1) { } else { echo " <a href='test1.php?pagenum=1'> <<-</a> "; echo " "; $previous = $pagenum-1; echo " <a href='test1.php?pagenum=$previous'> <-</a> "; } echo "Page $pagenum of $last "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='test1.php?pagenum=$next'>-></a> "; echo " "; echo " <a href='test1.php?pagenum=$last'>->></a> "; } ?> Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/154536-solved-pagination-error/ Share on other sites More sharing options...
ober Posted April 17, 2009 Share Posted April 17, 2009 $pagenum must be 0. You can't have a negative in a limit. Quote Link to comment https://forums.phpfreaks.com/topic/154536-solved-pagination-error/#findComment-812542 Share on other sites More sharing options...
timmah1 Posted April 17, 2009 Author Share Posted April 17, 2009 Thanks ober, but I fixed it. I was trying to get the $page_rows with nothing to show I just added an if statement $data = mysql_query("SELECT * FROM wishlist") or die(mysql_error()); $rows = mysql_num_rows($data); if($numrows == 0){ echo "<font color='#c60001'>No Items As Of Yet</font>"; } and it fixed the problem Thank you Quote Link to comment https://forums.phpfreaks.com/topic/154536-solved-pagination-error/#findComment-812545 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.