I assume you use a Unix like system for your server.
I assume you have your PHP scripts in ~/public_html
Then you can create a directory ~/mypasswords
Now you can create the following file
--- ~/mypasswords/mysql.log.data.php ---
-- eof ---
Now in your php script that users can surf to
--- ~/public_html/index.php ---
mysql_connect($mysql_host, $mysql_login, $mysql_passw);
//and so on...
--- eof ---
Even if there would be a misconfiguration, and the PHP engine would be
disabled, and the code is displayed in raw, no one will be able to see the
login/password/host/database in your code, just see to that the user who is
running the web server has the privileges to read the
~/mypasswords/mysql.log.data.php, but don't make the directory publicly
available on the net (no symlinks to the file or directory in your ~/public_html).