A Matter with mysql
#1
Sad 
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.
Reply
#2
$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;
Reply
#3
It's because $mybb->settings['advportal_max'] is not set to anything causing MySQL to generate an error.

Add this code before the query:

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)