Jump to content

Help with MySQL database in a php page


Guest austinlanham

Recommended Posts

Guest austinlanham

I have just started using PHP and MySQL for my webpage.To connect to the MySQL database, I have been been putting the following in my PHP scripts:$database = "my_db";$host = "servername";$db_user = "username";$db_pass = "password";$linkID = mysql_connect($host, $db_user, $db_pass);mysql_select_db("$database", $linkID);I don't like this because if someone downloads this file they have the server name, the username, and password of my database.How can I protect this page from being downloaded or encrypt this so that people couldn't read it if they got a hold of it?Thanks.

Link to comment
Share on other sites

How are they going to get a hold of it? Any code that is in between <?php and ?> brackets aren't visible by the viewer, unless it is echoed. So its completely safe. Unless somehow your FTP gets hacked and they get it, but thats an enormously slim possibility.

Link to comment
Share on other sites

If your concerned about your database information, create a separate file which contains this information and require it in every page. It also makes it easier if you for some reason have to change databases or usernames as one file needs to be changed rather than all of them.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...