MyBB Community Forums

Full Version: A Matter with mysql
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi all;
im making a plug-in, and i have to get the last threads from database
i put

$query = $db->query ("SELECT subject,username,uid,tid,replies FROM ".TABLE_PREFIX."threads WHERE visible='1' ".get_unviewable()." ORDER BY dateline DESC LIMIT 0,".$mybb->settings['advportal_max']."");


and getting this error:
MySQL 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 subject,username,uid,tid,replies FROM mybb_threads WHERE visible='1' ORDER BY dateline DESC LIMIT 0,


i have done the settings,templates but i get this problem

thanks.
PHP Code:
$unviewable get_unviewable_forums();
if(
$unviewable)
{
    
$unviewwhere " AND fid NOT IN ($unviewable)";
}
    
$query $db->query("
        SELECT subject,username,uid,tid,replies 
        FROM "
.TABLE_PREFIX."threads
        WHERE 1=1 $unviewwhere AND visible='1' AND closed NOT LIKE 'moved|%'
        ORDER BY lastpost DESC 
        LIMIT 0, "
.$mybb->settings['advportal_max']
    ); 

Just copied the code used in portal.php;
It's because $mybb->settings['advportal_max'] is not set to anything causing MySQL to generate an error.

Add this code before the query:

PHP Code:
if(!$mybb->settings['advportal_max'])
{
     
$mybb->settings['advportal_max'] = 20;


You can change the number of course.
thnx for your help,but wasnt causing from that :]
i've done it.
Reference URL's