I'm trying to create mySQL tables in PHP, but I can't seem to get the code to work. I've been learning PHP for about 2 days now, so if the code is way off... My bad.
Here it is:
<?php
$con = mysql_connect("localhost","username","password");
mysql_select_db("dbname");
$sql = "SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
DROP TABLE IF EXISTS mqs_users;
CREATE TABLE IF NOT EXISTS mqs_users (
id int(11) NOT NULL auto_increment,
username varchar(225) NOT NULL,
password varchar(225) NOT NULL,
email varchar(225) NOT NULL,
UNIQUE KEY id (id)
)";
if (!$con)
{
echo('Could not connect: ' . mysql_error());
exit;
}
if(mysql_query($sql))
{
echo "Table succesfull";
}
mysql_query($sql, $con);
?>
I need to know what I'm doing wrong.