Jump to content

can any one help with an error i keep getting


runnerjp

Recommended Posts

hey guys
ok 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]
Link to comment
Share on other sites

[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 results
while ($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 pages
echo "<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 links
if ($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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.