View Full Version : Non-object Issue
The-Ensemble
01-07-2008, 07:38 PM
Ok I have this line of text in my php functions admin file that keeps getting booted when executed. with the error
Fatal error: Call to a member function on a non-object in {file} on line 8
Line 8: $mainsqry = $vbulletin->db->query_read("SELECT favid, name, displayid FROM " . TABLE_PREFIX . "favavorites_main ORDER BY displayid");
Whats the problem? I've switched from $vbulletin->db to $db, that wasn't it, there query layout is the same as other parts of the file that works fine. I don't get what the problem is at all.
Help?
Opserty
01-07-2008, 08:16 PM
Post the lines above this line. (One line on its own its only good for solving syntax errors :p)
Most likely the vBulletin backend/core is not initiating correctly.
Marco van Herwaarden
01-08-2008, 06:59 AM
Is this code inside a function?
The-Ensemble
01-08-2008, 07:17 AM
Yes the code is inside a function, heres the function.
function get_mains()
{
$mainsqry = $vbulletin->db->query_read("SELECT favid, name, displayid FROM " . TABLE_PREFIX . "favavorites_main ORDER BY displayid");
$recordsetm = $db->fetch_array($mainsqry);
while($record = mysql_fetch_assoc($recordsetm)) {
$mains[$record['mainid']] = $record;
$mains[$record['mainid']][cats] = array();
}
return $mains;
}
Marco van Herwaarden
01-08-2008, 07:38 AM
The add the following as the first line of the function:
global $vbulletin;
The-Ensemble
01-08-2008, 07:43 AM
Thanks, I've added that and its rejecting the same line again.
Marco van Herwaarden
01-08-2008, 08:03 AM
change it to:
global $vbulletin, $db;
You use both $vbulletin and $db in your script.
Marco van Herwaarden
01-08-2008, 08:06 AM
Also, why do you use:
$recordsetm = $db->fetch_array($mainsqry);
while($record = mysql_fetch_assoc($recordsetm)) {
instead of:
while($record = $db->fetch_array($mainsqry)) {
The-Ensemble
01-08-2008, 08:27 AM
I was chopping and changing the coding various ways to see which part it was, I was going to revert it back after I'd got it working.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.