so i'm having my database connection in my project. The file has a local and an online request, one is commented out when i work on localhost.
is there a way in php for it to look up which one it has to use?
like if url = localhost/blabla use local else use online?
Here is the connection.
try{
//local connection
$db = new PDO('mysql:host = 127.0.0.1; dbname=XXXX', 'root','');
//local online
//$db = new PDO('mysql:host = XXXXX; dbname=XXXXX', 'xxxxx','*****');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e){
echo $e->getMessage();
die();
}
$db->exec("set names utf8");
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
Hope somone can help if it's possible, thanks
Aucun commentaire:
Enregistrer un commentaire