Greetings all,
I've been managing a PHP/MySQL website of my own for a while. On that site, I have a php file that is included (with the function of the same name) where database access is required. The file has the basic structure of:
$dbuser = "username";
$dbpass = "password";
$dbname = "database_name";
function runQuery($SQL) {
global $dbuser, $dbpass, $dbname;
$db = mysql_connect($dbname, $dbuser, $dbpass) or die(".....");
// more code here to run the sql statement and return results etc.
}
Since my personal site has nothing that needs to be totally secure, I don't worry too much that my database user and password are right there in a file. Plus, I took the precaution of making the file a .php file so that it can't be displayed in a browser (it'll be parsed first).
Now, however, as a part of my day-job, I'll be porting an existing web/database application to PHP/MySQL. What other precautions, if any, would you all suggest to protect these vital username/password combinations?