How do I hide my mySQL login info in my php script?

Issue

I have a great php mySQL login script that works fine. Is ther another way to provide all my access info without revealing it in the script? Right now I show all my security access info which I think is not safe.

Can I hide this?

Here is what I’m referring to:

    $host="localhost"; // Host name
$username="XXXXXXXXXX"; // Mysql username
$password="XXXXXXXXXX"; // Mysql password
$db_name="XXXXXXXXXXX"; // Database name
$tbl_name="XXXXXXXXXX"; // Table name

Solution

Create database.php, move your code snippet above to database.php, then ..

include "database.php";

At the top of each page that needs a database connection.

Answered By – Blake

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published