| 
	
 | 
 Posted by Jonathan on 08/09/06 07:54 
mpar612 wrote: 
> // Connect to the database 
> $db = 
> DB::connect('mysql://mikepar8_hockey:testing@216.246.48.250/mikepar8_mikeparkermusiccom'); 
 
One advice: Usenet is archived and your password will be visible for  
years on end, never post you actual connection string including  
passwords! It is even better not to hardcode them, especially not in the  
script file itself. 
 
I'm not claiming that it is the only and the best solution but I usually  
use an include file for the parameters and place this include file in a  
directory that is only readable to the web server daemon. You can reuse  
this include file every time you need it so you only have to configure  
the connection once and also have to change parameters in one file only. 
 
In your include file you could define your dsn: 
 
$dsn = 'mysql://someuser:apasswd@hostname/thedb' 
 
or more readable: 
 
$dsn = array( 
     'phptype'  => 'mysql', 
     'username' => 'someuser', 
     'password' => 'apasswd', 
     'hostspec' => 'hostname', 
     'database' => 'thedb', 
); 
 
Connecting would than easily be: 
 
$db =& DB::connect($dsn); 
 
Last advice... the PEAR/DB package is no longer maintained and is  
superseded by PEAR/MDB2. It depends on your way of coding, but it is  
quite easy to modify your code to use MDB2 instead of DB. Documentation  
for MDB2: http://pear.php.net/manual/en/package.database.mdb2.php  
(Although it is still not complete: http://pooteeweet.org/blog/336) 
 
For more info on migrating: http://www.phpied.com/db-2-mdb2/ 
 
Good luck, 
 
Jonathan
 
  
Navigation:
[Reply to this message] 
 |