For my school project I need to recover some information one database and associate with another database. But for that I want to use a ini file because if the log for connection of one data base change, I don't want to change it in the code.
My code is :
<?php
// On recupére les info dans fichier ini pour mySQL
//Get Information in ini for mySQL
$fichier = 'BDDconnexion.ini';
if(file_exists($fichier)){
$config = parse_ini_file($fichier,true);
$ip = "$config['mySQL'][ip]";
$port = "$config['mySQL'][port]";
$nomBDD = "config['mySQL'][nomBDD]";
$login = "$config['mySQL'][login]";
$password = "$config['mySQL'][password]";
}
// On se connecte à MySQL
//Connexion to MySQL
try {
$bdd = new PDO(mysql . ':host='.$ip.'dbname='.$nomBDD,$login,$password,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
catch (Exception $e)
{
die('Erreur : '. $e->getMessage());
}
?>
It is not working and i have this error message :
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\connectmySQL.php on line 14.
And the composition of my ini file is :
[mySQL]
ip="127.0.0.1"
port=4900
nomBDD=MagicCash
login="******"
password=""
Can someone help me ?