Well, IMHO I think you need to make sure that your HTTP server's configuration is secured. I mean nobody can get RAW .php files from the server.
OR in case you are not sure, you can place the password inside a file (outside of your documentroot / WWWROOT). Then all you need is add some codes in the php file that connects to the database to read the file that contains the password. For example, you put the password in a file named 'password' in the path /home/tom/
All you need to do is include the following code in the calling file (before connecting to the database)
$file = file("/home/tom/password","r");
This will put the first line of the file 'password' in an array named $file. This means that the password in contained in $file[0]
And then you just include $file[0] as the password in the mysql_connect(...)
Anyway this is my opinion, I am not that good 😉
If anybody feels that this way is incorrect, do tell me. Thanks.