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`) ); Link to comment https://forums.phpfreaks.com/topic/194588-mysql_queryfile_get_contentsimport-dbsql-or-diemysql_error/ 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. Link to comment https://forums.phpfreaks.com/topic/194588-mysql_queryfile_get_contentsimport-dbsql-or-diemysql_error/#findComment-1023389 Share on other sites More sharing options...
scarhand Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks. Link to comment https://forums.phpfreaks.com/topic/194588-mysql_queryfile_get_contentsimport-dbsql-or-diemysql_error/#findComment-1023390 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. Link to comment https://forums.phpfreaks.com/topic/194588-mysql_queryfile_get_contentsimport-dbsql-or-diemysql_error/#findComment-1023410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.