Jump to content

how to make mysql_connect() more secure?


airwinx

Recommended Posts

Hi,
As we know when you want to connect to ur mysql db, we normally use this $query=mysql_connect(...);,
I wonder how should I make this more secure so that someone can't view my dbname, user & password?
I have a php file that store all my infor of my mysql information, so when ever someone in my company browse through the file from the server they will see my db information(my password & userid).
can someone has better idea of how should I store my db infor more secure........ :o
Link to comment
https://forums.phpfreaks.com/topic/28527-how-to-make-mysql_connect-more-secure/
Share on other sites

Hi,
here it how it look in my php file that store my db infor:

<?
$db_user="abc";
$db_pass="xyz_sample",
$db = mysql_connect("localhost","$db_user","$db_pass") or die("cannot connect to db");
$dbname = mysql_select_db("testing") or die("cannot connect to the db");
?>
[code]
<?
function dbconnect($host, $username, $password, $database){
global $link;
$link = mysql_connect("$host","$username","$password");
mysql_select_db("$database");
}
?>
[/code]

that way you can call the function, it will connect, and your user/password dont leave the function.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.