Re: passing a mysqli object via globals

From: Date: Tue, 04 Dec 2007 09:47:34 +0000
Subject: Re: passing a mysqli object via globals
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-44387@lists.php.net to get a copy of this message
Chris wrote:
julian wrote:
warn: already posted in general.... with no response... maybe is too basic.. but I RTFM and still is not clear to me what I am doing wrong.... I want to open a database connection at program initialization and use that very same connection via globals initilizating ( loading from db) other objects. Basically index.php require_once ('file.php'); $db=new mysqli(host,us,pass,db);
The order of this stuff matters. $db isn't set up when you include file.php, hence why it's not an object when you try to use it. move the $db = .. line above the file.php reference. [ I'm sure you would have received a notice or warning or something if you had error_reporting set to E_ALL and display errors on ]
Hi Chris, Thanks for your comments. I do have E_ALL set. Your view does no explain why in one class it does work and in the other class it does not. Both classes defined in same file. However, I will try later in the day you idea and will post results. many thanks. JCG

« previous php.db (#44387) next »