views:

104

answers:

2
+1  Q: 

Mysql Syntax Error

Any idea why this is popping up :( ?

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 'CREATE TABLE `clocks` ( `id` int(11) NOT NULL AUTO_INCREMENT, ' at line 6

** Here is the query **

CREATE TABLE `clients` (
                          `id` int(11) NOT NULL AUTO_INCREMENT,
                          `clientname` varchar(255) DEFAULT NULL,
                              PRIMARY KEY (`id`)
                        ) ENGINE=MyISAM AUTO_INCREMENT=127 DEFAULT CHARSET=latin1;
                        CREATE TABLE `clocks` (
                          `id` int(11) NOT NULL AUTO_INCREMENT,
                          `projid` int(11) DEFAULT NULL,
                          `staffid` int(11) DEFAULT NULL,
                          `clientid` int(11) DEFAULT NULL,
                          `desc` longtext,
                          `hours` varchar(255) DEFAULT NULL,
                          `date` int(11) DEFAULT NULL,
                          PRIMARY KEY (`id`)
                        ) ENGINE=MyISAM AUTO_INCREMENT=26 DEFAULT CHARSET=latin1;
                        CREATE TABLE `config` (
                          `id` int(11) NOT NULL AUTO_INCREMENT,
                          `key` varchar(255) DEFAULT NULL,
                          `value` longtext,
                          PRIMARY KEY (`id`)
                        ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
                        CREATE TABLE `projects` (
                          `id` int(11) NOT NULL AUTO_INCREMENT,
                          `clientid` int(11) DEFAULT NULL,
                          `projectname` varchar(255) DEFAULT NULL,
                          `projectdesc` longtext,
                          PRIMARY KEY (`id`)
                        ) ENGINE=MyISAM AUTO_INCREMENT=36 DEFAULT CHARSET=latin1;
                        CREATE TABLE `staff` (
                          `id` int(11) NOT NULL AUTO_INCREMENT,
                          `email` varchar(255) DEFAULT NULL,
                          `password` varchar(255) DEFAULT NULL,
                          `name` varchar(255) DEFAULT NULL,
                          `active` int(11) DEFAULT NULL,
                          `type` varchar(255) DEFAULT NULL,
                          PRIMARY KEY (`id`)
                        ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;
                        CREATE TABLE `temp_clocks` (
                          `id` int(11) DEFAULT NULL,
                          `projid` int(11) DEFAULT NULL,
                          `staffid` int(11) DEFAULT NULL,
                          `clientid` int(11) DEFAULT NULL,
                          `desc` longtext,
                          `timestamp` int(11) DEFAULT NULL
                        ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+2  A: 

You didn't separate multiple queries with a semicolon.

Also, mysql_query doesn't take multiple queries. Use the new mysqli extension and mysqli::multi_query for that.

Tor Valamo
how do you do it :| ?
tarnfeld
I will post all the query... hold on
tarnfeld
THANKS!!! :D wooo
tarnfeld
A: 

You've specified a size of 11 for an int type - but this only comes in 1,2,,4 and 8 byte flavours and IIRC the size is implicit in the type (tinyint, smallint, mediumint, int and bigint).

C.

symcbean
That's not correct; the 11 refers to the width of the field. This refers purely to the formatting of the field when it's printed, i.e. if the number is less than 11 digits long, it should be left-padded with spaces. See http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html
Dancrumb
I was going to say, 11 is right?
tarnfeld