This is one of my script that I was working on but I just can't figure out what's wrong.
$dbhost = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "str_academy";
$connect = mysqli_connect("$dbhost", "$dbusername", "$dbpassword");
if (!$connect) {
echo("<div class='container'>");
echo("<div class='alert alert-danger'><strong>Warning! </strong>Couldn't create the specified database</div>");
echo("</div>");;
exit();
}else {
echo("<div class='container'>");
echo("<div class='alert alert-success'><strong>Success! </strong>Database connection established successfully</div>");
echo("</div>");;
}
if ($connect) {
$database_create = 'CREATE DATABASE str_academy';
$database_query = mysqli_query($connect, $database_create);
if (!$database_query) {
echo("<div class='container'>");
echo("<div class='alert alert-danger'><strong>Warning! </strong>Couldn't create the specified database</div>");
echo("</div>");
exit();
}else {
echo("<div class='container'>");
echo("<div class='alert alert-success'><strong>Success! </strong>Database : str_academy successfully created</div>");
echo("</div>");
}
}
$database_select = mysqli_select_db($connect, "str_academy");
if (!$database_select) {
echo "Select a database first";
}else {
echo "Database Selected";
}
$contact_table_create = "CREATE TABLE contact_information (
contact_id INT NOT NULL AUTO_INCREMENT,
contact_name VARCHAR(255) NOT NULL,
contact_email TEXT NOT NULL,
phonenumber INT(11) REAL NULL,
message TEXT NOT NULL,
PRIMARY KEY(contact_id)
)";
$contact_table_query = mysqli_query($connect, $contact_table_create);
if (!$contact_table_query) {
echo "Table not created";
}else {
echo "Table created";
}
?>
I've created this simple test script. Everything seems to be running perfectly except that it is not creating the table contact_information. Can anyone help me solve this problem?
mysqli_error()return?'REAL:-) But yes, that's the way to get into the debugging of scripts.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REAL NULL, message TEXT NOT NULL, PRIMARY KEY(contact_id) )' at line 5. Going to postulate that this is something to do with your usage of theREALkeyword