runnerjp Posted December 5, 2006 Share Posted December 5, 2006 hey guysok why do i keep getting this error and hopw can i solve it lol ...short sweet and down to point lol[code]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 '-2,2' at line 1[/code] Quote Link to comment Share on other sites More sharing options...
sanfly Posted December 5, 2006 Share Posted December 5, 2006 Like it says, there is an error in the syntax of your mysql_queryYou will need to post your code so we can try and help you find the problem Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 5, 2006 Author Share Posted December 5, 2006 [code]{$pagenum = 1;}elseif ($pagenum > $last){$pagenum = $last;}//This sets the range to display in our query$max = 'ORDER BY blog_id DESC limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;?><table cellpadding="4" cellspacing="0" width="100%"><?//This is your query again, the same one... the only difference is we add $max into it$data_p = mysql_query("SELECT * FROM $table_name $max") or die(mysql_error());//This is where you display your query resultswhile ($row = mysql_fetch_array($data_p)) {$text = "$row[blog_content]";$good_text = stripslashes($text);$wrapped = wordwrap($good_text, 70, "\n", 1);$message = nl2br($wrapped);if($auth[login] == "admin") {$show_del = "<a href=\"admin_delblog.php?blog_id=$row[blog_id]&blog_title=$row[blog_title]\"><img src=\"$imgdir/trash.gif\" align=\"absmiddle\" border=\"0\"alt=\"Delete post\"></a> ";}echo "<tr> <td width=\"424\" class=\"blog_title\"> <p>Posted by: <a href=\"$userurl/$row[url]\">$row[author]</a> $show_del</p> </td> <td width=\"543\" class=\"blog_title\"> <p>Date: $row[blog_date]</p> </td> </tr> <tr> <td width=\"975\" colspan=\"2\" class=\"blog_title\"> <p>Title: $row[blog_title]</p> </td> </tr> <tr> <td width=\"971\" colspan=\"2\" class=\"blog_entry\"> <p>$message</p> </td> </tr><tr><td colspan=\"2\"><p><hr></p></td></tr>";}?></table><?// This shows the user what page they are on, and the total number of pagesecho "<p align=\"center\"> --Page $pagenum of $last-- </p>";?><p align="center"><?// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page//so we do nothing. If we aren't then we generate links to the first page, and to the previous page.if ($pagenum == 1){}else{echo " <a href='{$_SERVER['PHP_SELF']}?comm_id=$comm_id&pagenum=1'> <img src=\"$imgdir/icons/$site_ico_set/home.gif\" border=\"0\" alt=\"Home\"></a></a> ";echo " ";$previous = $pagenum-1;echo " <a href='{$_SERVER['PHP_SELF']}?comm_id=$comm_id&pagenum=$previous'> <img src=\"$imgdir/icons/$site_ico_set/back.gif\" border=\"0\" alt=\"Back\"></a></a> ";}//This does the same as above, only checking if we are on the last page, and then generating the Next and Last linksif ($pagenum == $last){}else {$next = $pagenum+1;echo " <a href='{$_SERVER['PHP_SELF']}?comm_id=$comm_id&pagenum=$next'><img src=\"$imgdir/icons/$site_ico_set/next.gif\" border=\"0\" alt=\"Next\"></a></a> ";echo " ";}?></p>[/code]thats my blog sript :D Quote Link to comment Share on other sites More sharing options...
sanfly Posted December 5, 2006 Share Posted December 5, 2006 Okay, i think the problem is the limit that its calculating. The lower limit is -2, which is below 1 so therefore does not exist.I think you need to check the calculations through which you come up with the limits Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 5, 2006 Author Share Posted December 5, 2006 how have i dun it wrong tho :S Quote Link to comment Share on other sites More sharing options...
sanfly Posted December 5, 2006 Share Posted December 5, 2006 I Dont know, you will need to put the whole code in (you've cut off some at the top) Quote Link to comment Share on other sites More sharing options...
btherl Posted December 6, 2006 Share Posted December 6, 2006 Runnerjp, i would guess that pagenum is equal to 0, and pagerows is 2. ($pagenum -1) * $pagerows is -2, which is not what you want.If your page numbers start at 0, you should just use $pagenum * $pagerows. If your page numbers start at 1, then there is a bug where you set your page number, and that needs to be fixed. 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.