Hello dweds. As you know the code below creates a new
database & tables. Well the codes did work, it created a database but
not with the tables in it. Its kinda weird I tested the same codes but with different table names some hours ago and it worked, but now it does'nt.
I think theres something wrong with the table code which I cant figure out. I tried directly on SQL query and it shows the following error:
Error
SQL query:
mysql_select_db(
"game", $con
);
MySQL said:
#1064 - 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 'mysql_select_db("game", $con)' at line 1 Help would be appreciated alot. Thanks
CODE
<?php
$con = mysql_connect("localhost","root","secret");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}// Creates database
if (mysql_query("CREATE DATABASE game",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
//Creates tables in the database
mysql_select_db("game", $con);
$sql = "CREATE TABLE Users
(
usersID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(usersID),
Username varchar(32),
Password varchar(64),
Email varchar(64),
Gender ENUM('Male','Female'),
)";
mysql_query($sql,$con);
mysql_close($con);
?>