PDA

View Full Version : parse error :*(


N!ck
03-17-2002, 06:02 AM
$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! :)

Lesane
03-17-2002, 07:20 AM
U need to global the function "$DB_site->"

N!ck
03-17-2002, 01:56 PM
how is that done?

Lesane
03-17-2002, 03:17 PM
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");

N!ck
03-17-2002, 06:24 PM
i see...'cause it's in a function...gotcha...thanks

Admin
03-18-2002, 10:21 AM
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.