Hello
I am trying to create a table using the code below and am getting the error:
Datbase ERROR: CREATE TABLE links ( id INT NOT NULL AUTO_INCREMENT, sitename VARCHAR(50), siteurl VARCHAR(75), description TEXT, category VARCHAR(50), PRIMARY KEY(id) );
You have an error in your SQL syntax near '; ' at line 1Create Table Results RESULT =
Any ideas as to what the problem is?
<?
$usr = "mancroft";
$pwd = "xxxxxxxx";
$db = "mancroft_linksdb";
$host = "localhost";
/*== CONNECT TO DATABASE ==*/
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { print "ERROR: " . mysql_error() . "\n"; }
#select database to use
mysql_select_db($db, $cid);
/*== SETUP SQL STATEMENT ==*/
# create links table
$sql = " CREATE TABLE links (";
$sql .= " id INT NOT NULL AUTO_INCREMENT, ";
$sql .= " sitename VARCHAR(50), ";
$sql .= " siteurl VARCHAR(75), ";
$sql .= " description TEXT, ";
$sql .= " category VARCHAR(50), ";
$sql .= " PRIMARY KEY(id) ";
$sql .= " ); ";
/*== EXECUTE SQL STATEMENT ==*/
$result = mysql_query($sql, $cid);
if (mysql_error()) { print "Datbase ERROR: $sql <br>" . mysql_error(); }
# display result for table creation query
# this should be 1 on a success
print "Create Table Results RESULT = $result\n\n";
?>
I am trying to create a table using the code below and am getting the error:
Datbase ERROR: CREATE TABLE links ( id INT NOT NULL AUTO_INCREMENT, sitename VARCHAR(50), siteurl VARCHAR(75), description TEXT, category VARCHAR(50), PRIMARY KEY(id) );
You have an error in your SQL syntax near '; ' at line 1Create Table Results RESULT =
Any ideas as to what the problem is?
<?
$usr = "mancroft";
$pwd = "xxxxxxxx";
$db = "mancroft_linksdb";
$host = "localhost";
/*== CONNECT TO DATABASE ==*/
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { print "ERROR: " . mysql_error() . "\n"; }
#select database to use
mysql_select_db($db, $cid);
/*== SETUP SQL STATEMENT ==*/
# create links table
$sql = " CREATE TABLE links (";
$sql .= " id INT NOT NULL AUTO_INCREMENT, ";
$sql .= " sitename VARCHAR(50), ";
$sql .= " siteurl VARCHAR(75), ";
$sql .= " description TEXT, ";
$sql .= " category VARCHAR(50), ";
$sql .= " PRIMARY KEY(id) ";
$sql .= " ); ";
/*== EXECUTE SQL STATEMENT ==*/
$result = mysql_query($sql, $cid);
if (mysql_error()) { print "Datbase ERROR: $sql <br>" . mysql_error(); }
# display result for table creation query
# this should be 1 on a success
print "Create Table Results RESULT = $result\n\n";
?>