Re: passing a mysqli object via globals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux