Re: Security with dbHost, dbUser, dbPassword

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

 




----- Original Message ----- From: "Otto Wyss" <otto.wyss@xxxxxxxxxx>

What is the usual save way to store/use DB access info in a script. I currently just use some PHP variables in a file which I include in all other scripts.

config.php
<?PHP
  if (!defined ("config_include")) die ("Error...");
  $dbhost = "localhost";
  $dbuser = "name";
  $dbpass = "password";
  $dbname = "database";
  $dbcoll = "utf8_unicode_ci";
?>

Is this save enough or are there better ways? Where should I store this file so it isn't accessible via the net but inside scripts?

O. Wyss


Besides what Jochem has already sugested, I would add that I usually have in the include file, in an unaccessible path as he said, a function that returns a connection. The function has all the connection information local, so that they are neither global variables nor constants, just local literal values within the function. In the same function I put the call to mysql_select_db. Though I check the return values for errors, I usually ignore them since unless you have either more than one database engine or more than one database, the default link resource does not need to me explicitly passed to other functions.

Satyam

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux