$sql="CREATE TABLE syntax error
I create this file listed below but I am getting this error when I run it:
Can't create mp3_files table 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 'Name VARCHAR, Artist VARCHAR , Release_Date date, Additional
The syntax looks good to me does someone see something that I am missing??
<?php
$host= "localhost";
$dbuser= "unsernamer";
$dbpass= "password";
$database= "mp3_db";
$table= "mp3_files";
$link= @mysql_connect($host, $dbuser, $dbpass)
or die ('I cannot connect to the database because: ' . mysql_error());
if (! @mysql_select_db($database,$link)){
mysql_query("CREATE DATABASE $database");
}
else
{
$sql="CREATE TABLE $table (
id int NOT NULL AUTO_INCREMENT Primary Key,
Song Name VARCHAR,
Artist VARCHAR ,
Release_Date date,
Additional_Notes VARCHAR,
Path VARCHAR )";
$query1 = mysql_query($sql);
if ($query1){
print "<p>$table table created</p>";
} else {
$error = 1;
echo("<p>Can't create $table table ". mysql_error() ."<p>");
}
}
?>
|