Skip to content

Commit

Permalink
Update execute.php
Browse files Browse the repository at this point in the history
bug fix db create
  • Loading branch information
fherryfherry authored Jul 28, 2016
1 parent 5a82fe9 commit ed425ce
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions install/execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
$conf = load_env();

if($type=='save_db') {
$con = mysqli_connect($post['DB_HOST'],$post['DB_USERNAME'],$post['DB_PASSWORD']);
$con = mysqli_connect($post['DB_HOST'],$post['DB_USERNAME'],$post['DB_PASSWORD'],$post['DB_DATABASE']);

// Check connection
// Check connection
if (mysqli_connect_errno())
{
echo 0;
exit;
}
//CREATE DATABASE IF NOT EXISTS DBName;
@mysqli_query($con,"CREATE DATABASE IF NOT EXISTS `$post[DB_DATABASE]`");
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$conf['DB_HOST'] = $post['DB_HOST'];
$conf['DB_DATABASE'] = $post['DB_DATABASE'];
Expand All @@ -27,8 +24,16 @@
$env .= "$k=$v\n";
}

file_put_contents("../.env", $env);
echo 1;
if(is_writable("../.env")) {
if(file_put_contents("../.env", $env)) {
echo "success";
}else{
echo "Can't write setting to .env!";
}

}else{
echo "Please make sure file .env is writable!";
}
}elseif ($type=='check_table') {

$con = mysqli_connect($conf['DB_HOST'],$conf['DB_USERNAME'],$conf['DB_PASSWORD'],$conf['DB_DATABASE']);
Expand All @@ -44,4 +49,4 @@
}else{
echo 0;
}
}
}

0 comments on commit ed425ce

Please sign in to comment.