View Full Version : parse error :*(

17 Mar 2002, 08:02
$catsql = $DB_site->query("SELECT id, catname FROM ffacats ORDER BY catname");

This line produces an error "call to member function on non-object". Heeeelp! :)

17 Mar 2002, 09:20
U need to global the function "$DB_site->"

17 Mar 2002, 15:56
how is that done?

17 Mar 2002, 17:17
If you are including global.php or config or whatever then you can use: global $DB_site;

Or you can use simply this, this will always work:

$catsql = mysql_query("SELECT id, catname FROM ffacats ORDER BY catname");

17 Mar 2002, 20:24
i see...'cause it's in a function...gotcha...thanks

18 Mar 2002, 12:21
Yup. Functions has their own variables, so unless you global a variable inside a function, for example $one, $one inside the function will not be the same as $one outside the function.
And since you are using $DB_site as an object, you must globalize it first or PHP won't understand what you're trying to do with a variable which isn't even defined.