Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

mysql

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
like image 750
Erik Avatar asked Feb 23 '23 11:02

Erik


1 Answers

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.

like image 103
Blake Avatar answered Mar 08 '23 03:03

Blake