Re: problems with functions/included files/mysql resource

From: Date: Wed, 28 Mar 2007 04:15:26 +0000
Subject: Re: problems with functions/included files/mysql resource
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-43341@lists.php.net to get a copy of this message
Hi, > > In the function to connect to and select the database, I make the mysql-link > resource a global value. It sounds like you've misunderstood 'global' variable. The global statement needs to go inside the function where you want to use the variable, not where you assign it. This tells that function to access that variable from the global scope. You will need to have this variable available at the global scope. Creating it inside another function will not do, you must return that from the function to the global scope too e.g. <?php $db = new mysql; ... some code ... function UseDb() { global $db; ... some more code ... } ?> Niel

« previous php.db (#43341) next »