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();
}
#sostituire questa riga con le variabili per il nuovo utente e la sua password da inserire nella pagina precedente
########################################
# $DBuserName='eleuser'; $DBpassword='elepass';
try{
$sql = "CREATE DATABASE IF NOT EXISTS $DBname;";
$database->exec($sql);
}
catch(PDOException $e)
{
echo $sql . "
" . $e->getMessage();die();
}
try {
$sql="CREATE USER if not exists `$ELEuserName`@'$DBhostname' IDENTIFIED BY '$ELEpassword';";
$database->exec($sql);
# $sql= "GRANT ALL ON `$DBname`.* TO `roby`@'$DBhostname';";
# $database->exec($sql);
$sql= "GRANT ALL ON `$DBname`.* TO `$ELEuserName`@'$DBhostname';";
$database->exec($sql);
$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;
}
catch(PDOException $e)
{
echo $sql . "
" . $e->getMessage();die();
}
}
function db_err($step, $alert) {
global $DBhostname,$DBuserName,$DBpassword,$DBname,$DBPrefix;
echo "