[ciapug] DB Manager Configuration file best practice?

Chris Van Cleve vanish at dreamscapevisionery.com
Thu Mar 23 14:38:18 CST 2006


Scope shouldn't be an issue with constants. Is this PHP 5 by chance?  
If memory serves me correctly, I had to uses double quotes when  
defining constants in PHP 5 like so:

define("DB_USER", "wadearno_bvlt1");     // your MySQL username
define("DB_PASSWORD", "zorwvMw5OV2L");   // ...and password
define("DB_PASSWORD", "wadearno_bvlt1"); // the name of the database
define("DB_HOST", "localhost");          // mySQL Server (typically  
'localhost')

Dave's note about .inc is important. I usually get around it by  
naming my files .inc.php and keeping them out of the web server tree.

Chris VC

On Mar 23, 2006, at 2:20 PM, David Champion wrote:

> Is this a scope issue? You could include the _dbconfig.inc in your  
> class code, or wherever you're instantiating the db object, and set  
> the properties for the object...
>
> BTW - I would recommend that you don't name include files .inc. If  
> you don't specifically configure your web server to deny showing  
> this file type on every server you're using it on, people will be  
> able to do this:
>
> http://yourserver.com/_dbconfig.inc
>
> ... and see the contents of that file.
>
> -dc
>
> Wade Arnold wrote:
>> I am wondering if anyone has a best practice for setting up a  
>> configuration
>> file for my database connection variables
>> In the past I have used the code below but now that I am using  
>> classes it
>> fails to declare the constant. Any ideas or tidbits of wisdom?
>> Thanks;
>> Wade Arnold
>> <?php
>> // this will be in your DBManager.php
>> require_once dirname(__FILE__).'./conf/_dbconfig.inc';
>> echo DB_USER;
>> echo DB_PASSWORD;
>> echo DB_PASSWORD;
>> echo DB_HOST;
>> ?>
>> <?php
>> // name this file _dbconfig.inc
>> /**
>>  * Thide defines CONSTANTS
>>  */
>> define( 'DB_USER', 'wadearno_bvlt1' );      // your MySQL username
>> define( 'DB_PASSWORD', 'zorwvMw5OV2L' );  // ...and password
>> define( 'DB_PASSWORD', 'wadearno_bvlt1' );   // the name of the  
>> database
>> define( 'DB_HOST', 'localhost' );     // mySQL Server (typically
>> 'localhost')
>> ?>
>> _______________________________________________
>> ciapug mailing list
>> ciapug at cialug.org
>> http://cialug.org/mailman/listinfo/ciapug
>
>
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug



More information about the ciapug mailing list