2017-07-15, 07:34 PM
So I'm trying to use a pagination code I found and this is what I get:
I am using this:
Anybody got any suggestions?
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
1064 - 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 '' at line 1
Query:
SELECT * FROM mybb_threads WHERE fid='2' ORDER BY tid DESC LIMIT
I am using this:
<?php
// START VARS
$fid = 2; // FORUM ID
$perpage = 5; // ITEMS PER PAGE
$forumpath = ''; // FORUM PATH
$filename = ''; // NAME OF THE FILE
// END VARS
// START DONT TOUCH STUFF
chdir('$forumpath');
define("IN_MYBB", 1);
require('/global.php');
require_once MYBB_ROOT."inc/class_parser.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
$parser = new postParser;
chdir('');
// END DONT TOUCH STUFF
// INCOMING
$page = intval($mybb->input['page']);
// COUNT RECORDS
$query = $db->simple_select('threads', 'COUNT(*) AS threads', "fid='{$fid}'");
$num = $db->fetch_field($query, "threads");
// PAGING ( MULTI )
if($page)
{
$start = ($page - 1) * $perpage;
}
else
{
$start = 0;
$page = 1;
}
$multipage = multipage($num, $perpage, $page, $filename."?");
// GET THREADS
$query = $db->simple_select('threads', '*', "fid='{$fid}' ORDER BY tid DESC LIMIT {$limit}");
if($db->num_rows($query) > 0)
{
while($row = $db->fetch_array($query))
{
$query2 = $db->simple_select('posts', '*', "pid='{$row['firstpost']}'");
$row2 = $db->fetch_array($query2);
$date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
$time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);
$options = array(
"allow_html" => 1,
"allow_mycode" => 1,
"allow_smilies" => 1,
"allow_imgcode" => 1,
"allow_videocode" => 1,
"filter_badwords" => 1
);
$message = $parser->parse_message($row2['message'], $options);
echo("<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a> -
Posted: {$date} {$time} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br />");
echo("{$message}<br /><br />");
echo("Replies (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)<br />");
}
}
else
{
echo 'Nothing to display.';
}
?>
Anybody got any suggestions?