Jump to content

[SOLVED] One more table question :)


jeff5656

Recommended Posts

I get an error with this table.  I suspect it is in the enum line but it LOOKS ok to me!

 

Error: 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 '(20) NOT NULL, procedure varchar(20) NOT NULL, proc_type enum (`GC`,`NS`,`' at line 5: CREATE TABLE procedures ( proc_id int(11) NOT NULL auto_increment, pt_id int(11) NOT NULL, proc_date date(20) NOT NULL, procedure varchar(20) NOT NULL, proc_type enum (`GC`,`NS`,`Staff`) NOT NULL, dx varchar(20) NOT NULL, PRIMARY KEY (proc_id) )

 

<?php 

include ("connectdb.php");


$sql = "CREATE TABLE procedures
(
  proc_id int(11) NOT NULL auto_increment,
  pt_id int(11) NOT NULL,
  proc_date date(20) NOT NULL,
  procedure varchar(20) NOT NULL,
  proc_type enum ('GC','NS','Staff') NOT NULL,
  dx varchar(20) NOT NULL,
  
  PRIMARY KEY  (proc_id)
)";

// Execute query
mysql_query($sql) or die(mysql_error().": $sql");


?>

Link to comment
https://forums.phpfreaks.com/topic/137413-solved-one-more-table-question/
Share on other sites

ok, this worked in mysql:

 

<?php 

include ("connectdb.php");


$sql = "CREATE TABLE `procedures` (
  `proc_id` int(11) NOT NULL auto_increment,
  `pt_id` int(11) NOT NULL,
  `proc_date` date NOT NULL,
  `procedures` varchar(20) NOT NULL,
  `proc_type` enum('GC','NS','Staff') default NULL,
  `dx` varchar(20) NOT NULL,
  PRIMARY KEY  (`proc_id`)
)";

// Execute query
mysql_query($sql) or die(mysql_error().": $sql");


?>

corrected......

<?php 

include ("connectdb.php");


$sql = "CREATE TABLE `procedures` (
  `proc_id` int(11) NOT NULL auto_increment PRIMARY KEY,
  `pt_id` int(11) NOT NULL,
  `proc_date` date NOT NULL,
  `procedures` varchar(20) NOT NULL,
  `proc_type` enum('GC','NS','Staff') NOT NULL,
  `dx` varchar(20) NOT NULL)";

// Execute query
mysql_query($sql) or die(mysql_error().": $sql");

?>

Yes good lesion here, All mysql error's are before the error line what is shown.

 

So if it says line 5 like it did trust me it on line 4 lol.

 

weired but true..

 

For some reason mysql spits the line afther the error out but we no it the line before..

 

make no scence when it tells you it the line it showing like line 5 but problam on line 4.

 

 

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.