I'm trying to pull a category list from the same database and I keep receiving an error.
Here is what my smarty tag says:
global $gCms;
global $db;
$vars = $gCms->variables;
$q= "SELECT zen_categories_name FROM zen_categories_description ASC";
$dbresult = $db->Execute($q);
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."";
}
if ($dbresult > 0) {
$row = $dbresult->FetchRow();
echo $row['categories_name'];
}
This is the error I'm getting:
Fatal error: Call to a member function on a non-object in /usr/home/sites/XXXXXXXXXXXXXXXXX/web/lib/content.functions.php(669) : eval()'d code on line 7
Now matter how I change the sql etc.
Hope someone can help.
I need to be able to do this in a few different sites.
Thanks in advance.
Kim
Adding a seperate sql query using addtional table in same database.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Adding a seperate sql query using addtional table in same database.
$db isn't a global anymore (not for a long time)...
and in 2.0, $gCms won't be either
use this:
and in 2.0, $gCms won't be either
use this:
Code: Select all
$db =& $gCms->GetDb();
$variables =& $gCms->variables;
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Adding a seperate sql query using addtional table in same database.
Okay, this is what we have now... but it is still giving us a Fatal Error.
Any other suggestions??
$db =& $gCms->GetDb();
$variables =& $gCms->variables;
$q= "SELECT zen_categories_name FROM zen_categories_description ASC";
$dbresult = $db->Execute($q);
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."";
}
if ($dbresult > 0) {
$row = $dbresult->FetchRow();
echo $row['categories_name'];
}
Any other suggestions??
$db =& $gCms->GetDb();
$variables =& $gCms->variables;
$q= "SELECT zen_categories_name FROM zen_categories_description ASC";
$dbresult = $db->Execute($q);
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."";
}
if ($dbresult > 0) {
$row = $dbresult->FetchRow();
echo $row['categories_name'];
}
-
- Forum Members
- Posts: 11
- Joined: Tue Apr 24, 2007 5:51 pm
Re: Adding a seperate sql query using addtional table in same database.
Please paste your entire plugin and the error result you get. Should be able to help from there. If that _is_ your entire plugin, re-add "global $gCms" to the top.
Re: Adding a seperate sql query using addtional table in same database.
Thank you very much...it worked like a charm....