This is a simple statement to draw some info on a home page regarding user stats .. right now the error i get is
Quote:
Invalid SQL:
SELECT userid, username FROM myprefix_user WHERE myprefix_userid=2;
MySQL Error : Unknown column 'myprefix_userid' in 'where clause'
Error Number : 1054
|
I changed the prefix in this example, but the correct prefix is in the error. What exactly is it complaining about?
Code:
// forum stats start
$numbersmembers = $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user");
$numbermembers = number_format($numbersmembers['users']);
$counter = $db->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post");
$totalposts=number_format($counter['posts']);
$countthreads = $db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");
$totalthreads=number_format($countthreads['threads']);
// forum stats end
// total online start
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$headerguests=$db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "session WHERE userid=0 AND lastactivity>$datecut");
$headerusers=$db->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM " . TABLE_PREFIX . "session WHERE " . TABLE_PREFIX . "session.userid>0 AND " . TABLE_PREFIX . "session.lastactivity>$datecut");
$headerguests=$headerguests[count];
$headerusers=$headerusers[count];
$totalonline=$headerguests+$headerusers;
// total online end
// get newest member name and userid start
$getnewestmember=$db->query_first("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE " . TABLE_PREFIX . "userid=$numbersmembers[max]");
$newusername = $getnewestmember['username'];
$newuserid = $getnewestmember['userid'];
// get newest member name and userid end