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
https://forums.phpfreaks.com/topic/19273-problem-with-create-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.