Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create table error

Status
Not open for further replies.

mancroft

Programmer
Oct 26, 2002
267
GB
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 = &quot;mancroft&quot;;
$pwd = &quot;xxxxxxxx&quot;;
$db = &quot;mancroft_linksdb&quot;;
$host = &quot;localhost&quot;;
/*== CONNECT TO DATABASE ==*/
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { print &quot;ERROR: &quot; . mysql_error() . &quot;\n&quot;; }

#select database to use
mysql_select_db($db, $cid);

/*== SETUP SQL STATEMENT ==*/
# create links table
$sql = &quot; CREATE TABLE links (&quot;;
$sql .= &quot; id INT NOT NULL AUTO_INCREMENT, &quot;;
$sql .= &quot; sitename VARCHAR(50), &quot;;
$sql .= &quot; siteurl VARCHAR(75), &quot;;
$sql .= &quot; description TEXT, &quot;;
$sql .= &quot; category VARCHAR(50), &quot;;
$sql .= &quot; PRIMARY KEY(id) &quot;;
$sql .= &quot; ); &quot;;

/*== EXECUTE SQL STATEMENT ==*/
$result = mysql_query($sql, $cid);
if (mysql_error()) { print &quot;Datbase ERROR: $sql <br>&quot; . mysql_error(); }
# display result for table creation query
# this should be 1 on a success
print &quot;Create Table Results RESULT = $result\n\n&quot;;
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top