Jump to content

Problem with Create Table


andyg666

Recommended Posts

I'm using XAMPP, with PHP 5 and MySQL 5. I have created a database and I am attempting to use the following PHP code to create tables:

[code]mysql_select_db("my_db", $con);

$sql = "CREATE TABLE tblActivity
(
ActivityID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(ActivityID),
LocationID int,
ActivityType varchar(15),
Accessibility text,
Popularity int(2),
AvgPopulation int(7),
Keywords text,
Description text,
CreatedBy varchar(15),
CreationDate datetime(yyyy-mm-dd hh:mm:ss),
ModifyDate datetime(yyyy-mm-dd hh:mm:ss)
)";

$result = mysql_query($sql,$con);
if (!$result)
  {
  die("Could not create tblActivity: " . mysql_error() . "<BR>");
  }
  else
  {
  echo "Creating tblActivity...<br>";
  }
[/code] 

This code returns the following error message:

[quote]"Could not create tblActivity: 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 '(yyyy-mm-dd hh:mm:ss), ModifyDate datetime(yyyy-mm-dd hh:mm:ss) )' at line 13"
[/quote]

I'm not sure what is incorrect--I've checked this against tons of examples and tutorials. I can't find any errors in the syntax. Any ideas?

Thanks!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.