Search code examples
sqlmysqlmysql-error-1064

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;

Solution

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