Re: Proper coding?
| From: | Jason Barnett | Date: | Tue, 30 Mar 2004 02:27:44 +0000 |
| Subject: | Re: Proper coding? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23299@lists.php.net to get a copy of this message | ||
Jim Macdiarmid wrote:
In the index.php file I have the following code: require_once('include/db_connect.php'); require_once('include/db_functions.php'); /* includes commonly used functions */ require_once('common.php'); $sphist_rec_count = GetRecCount('RecentActiveSpaces','RECENT_SPACE_COUNT'); In my db_functions.php, I have the function called GetRecCount(). It basically retrieves the Record count from a mySQL table. For some reason, the "db_object" object doesn't get created unless I include the db_connect.php inside the GetRecCount function. SomethingThis sounds like a problem with your PEAR::DB object's scope. Without more information about your db_connect file it's hard to say exactly what's wrong. However, you if you go to this page you should be able to figure out what's wrong: http://www.zend.com/manual/language.variables.scope.php
tells me that this is not proper Coding, and I was wondering if someone could tell me if there is another way to do this?common.php: require_once 'include/db_functions.php'; require_once 'include/db_connect.php'; index.php: require_once 'common.php'; Now any file that uses common.php will have access to db_connect.php and db_functions.php
Thanks, Jim