PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false);
$user=$DBuserName;
$password=$DBpassword;
if($DBPrefix == '') {
db_err ('stepBack','Non avete indicato il prefisso tabelle database.');
}
try {
$database = new PDO($dsn, $user, $password, $opt);
}
catch(PDOException $e)
{
echo $sql . "
" . $e->getMessage();die();
}
try{
$sql = "CREATE DATABASE IF NOT EXISTS $DBname;";
$database->exec($sql);
}
catch(PDOException $e)
{
echo $sql . "
" . $e->getMessage();die();
}
if(phpversion()>="5.7.6")
{
try {
$sql="CREATE USER if not exists '$ELEuserName'@'$DBhostname' IDENTIFIED BY '$ELEpassword';";
$database->exec($sql);
}
catch(PDOException $e)
{
echo $sql . "
" . $e->getMessage();die();
}
try {
$sql= "GRANT ALL ON `$DBname`.* TO `$ELEuserName`@'$DBhostname';";
$database->exec($sql);
}
catch(PDOException $e)
{
echo $sql . "
" . $e->getMessage();die();
}
}else{
try {
$sql="grant all on `$DBname`.* TO '$ELEuserName'@'$DBhostname' IDENTIFIED BY '$ELEpassword';";
$database->exec($sql);
}
catch(PDOException $e)
{
echo $sql . "
" . $e->getMessage();die();
}
}
$sql= "FLUSH PRIVILEGES;";
$database->exec($sql);
$sql = "use $DBname";
$database->exec($sql);
$sql = file_get_contents('sql/eleonline.sql');
$qr = $database->exec($sql);
$DBcreated = 1;
}
function db_err($step, $alert) {
global $DBhostname,$DBuserName,$DBpassword,$DBname,$DBPrefix;
echo "