----- 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