Re: passing a mysqli object via globals

From: Date: Mon, 03 Dec 2007 23:21:01 +0000
Subject: Re: passing a mysqli object via globals
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-44384@lists.php.net to get a copy of this message
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 ] -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.db (#44384) next »