Created
September 16, 2016 11:53
-
-
Save ron4stoppable/d994d520c9a5141e469897a6cef9704d to your computer and use it in GitHub Desktop.
Detect and connect to db server with proper configuration. The code check if the web app is hosted at localhost or a web server and load proper db configuration.
This file contains 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
$local = array( | |
'127.0.0.1', | |
'::1' | |
); // localhost | |
if(!in_array($_SERVER['REMOTE_ADDR'], $local)){ | |
require_once('connection-db.php'); // db connection details for server | |
} | |
else{ | |
require_once('db-connect-local.php'); // db connection details for localhost | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment