scarhand Posted March 9, 2010 Share Posted March 9, 2010 This code: mysql_query(file_get_contents('import-db.sql')) or die(mysql_error()); Is throwing this 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 'CREATE TABLE IF NOT EXISTS `replies` ( `id` int(10) unsigned NOT NULL AUTO_IN' at line 8 Heres the contents of import-db.sql: CREATE TABLE IF NOT EXISTS `categories` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `slug` varchar(255) NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS `replies` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_thread` int(10) unsigned NOT NULL, `username` varchar(255) NOT NULL, `body` text NOT NULL, `the_date` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) ); Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 9, 2010 Share Posted March 9, 2010 You can not batch SQL. You have to do one query at a time. Quote Link to comment Share on other sites More sharing options...
scarhand Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 9, 2010 Share Posted March 9, 2010 Just to be clear, that is an issue with the mysql_query() function in php. Obviously you can run batch mysql scripts through the mysql command line client. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.