Created
January 9, 2013 21:55
-
-
Save simeondahl/4497315 to your computer and use it in GitHub Desktop.
Secure MySQL-connect script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Mysql settings | |
| $mysql['enabled'] = true; // Enable MySQL | |
| $mysql['host'] = "localhost"; // Host | |
| $mysql['user'] = "root"; // Username | |
| $mysql['pass'] = "1234"; // Password | |
| $mysql['db'] = "my_base"; // Database | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require("config.php"); | |
| // If mysql is enabled, then it will go further | |
| if ($mysql['enabled']) { | |
| $mysql['user'] = mysql_real_escape_string($mysql['user']); | |
| $mysql['pass'] = mysql_real_escape_string($mysql['pass']); | |
| $con = mysql_connect( $mysql['host'] , $mysql['user'] , $mysql['pass'] , $mysql['db'] ); | |
| if (!$con) { | |
| die("Can't connect to MySQL: ". mysql_error()); | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment