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
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");
?>
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.