diff --git a/install.php b/install.php index 5187e07..63716bf 100644 --- a/install.php +++ b/install.php @@ -8,19 +8,25 @@ */ require_once('functions.php'); if(isset($_POST['host'])) { - // create file 'dbinfo.php' - $fp = fopen('dbinfo.php','w'); - $l1 = '$host="'.$_POST['host'].'";'; - $l2 = '$user="'.$_POST['username'].'";'; - $l3 = '$password="'.$_POST['password'].'";'; - $l4 = '$database="'.$_POST['name'].'";'; - $l5 = '$compilerhost="'.$_POST['chost'].'";'; - $l6 = '$compilerport='.$_POST['cport'].';'; - fwrite($fp, ""); - fclose($fp); - include('dbinfo.php'); + + // connect to the MySQL server - mysql_connect($host,$user,$password); + $link=mysql_connect($_POST['host'],$_POST['username'],$_POST['password']); + if (!$link) { + die('Could not connect:' ); + } + else { + // create file 'dbinfo.php' + $fp = fopen('dbinfo.php','w'); + $l1 = '$host="'.$_POST['host'].'";'; + $l2 = '$user="'.$_POST['username'].'";'; + $l3 = '$password="'.$_POST['password'].'";'; + $l4 = '$database="'.$_POST['name'].'";'; + $l5 = '$compilerhost="'.$_POST['chost'].'";'; + $l6 = '$compilerport='.$_POST['cport'].';'; + fwrite($fp, ""); + fclose($fp); + include('dbinfo.php'); // create the database mysql_query("CREATE DATABASE $database"); mysql_select_db($database) or die('Error connecting to database.'); @@ -81,6 +87,7 @@ mysql_query($sql); header("Location: install.php?installed=1"); } + } ?>