Perad Posted January 5, 2010 Share Posted January 5, 2010 This is a bit odd to be honest. I have created a back up script which will rip out the clients database and files and save them to a tarball. This error is occurring in the restore script. function update_table($query) { // Earlier function switched DB to ma - switch back - execute query global $site; $conn = new WebPage (null, db_connect ('mysql://'.$site['mysql']['user'].':'.$site['mysql']['pass'].'@'.$site['mysql']['host'].'/'.$site['mysql']['db'])); mysql_query($query) or die(mysql_error()); } This connects to the database. $query contains the sql. A sample of the sql is below. DROP TABLE IF EXISTS `billinginfo`;CREATE TABLE `billinginfo` (`id` int(5) unsigned NOT NULL AUTO_INCREMENT,`active` int(1) unsigned NOT NULL DEFAULT '0',`sort` double unsigned NOT NULL DEFAULT '0',`stamp` int(10) unsigned NOT NULL DEFAULT '0',`name` varchar(250) NOT NULL,`name_parsed` varchar(250) NOT NULL,`firstname` varchar(250) NOT NULL,`lastname` varchar(250) NOT NULL,`address` varchar(250) NOT NULL,`city` varchar(250) NOT NULL,`state` varchar(250) NOT NULL,`zip` varchar(250) NOT NULL,`phone` varchar(250) NOT NULL,`cc_number` varchar(250) NOT NULL,`cc_expiry` varchar(250) NOT NULL,`promo_code` varchar(250) NOT NULL,`cc_type` varchar(250) NOT NULL,primary key(id)); SQL 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 `billinginfo` (`id` int(5) unsigned NOT NULL AUTO_INCREMENT,`active' at line 1 PLease Note: The following queries executed in the script separately work just fine. DROP TABLE IF EXISTS `billinginfo`; CREATE TABLE `billinginfo` (`id` int(5) unsigned NOT NULL AUTO_INCREMENT,`active` int(1) unsigned NOT NULL DEFAULT '0',`sort` double unsigned NOT NULL DEFAULT '0',`stamp` int(10) unsigned NOT NULL DEFAULT '0',`name` varchar(250) NOT NULL,`name_parsed` varchar(250) NOT NULL,`firstname` varchar(250) NOT NULL,`lastname` varchar(250) NOT NULL,`address` varchar(250) NOT NULL,`city` varchar(250) NOT NULL,`state` varchar(250) NOT NULL,`zip` varchar(250) NOT NULL,`phone` varchar(250) NOT NULL,`cc_number` varchar(250) NOT NULL,`cc_expiry` varchar(250) NOT NULL,`promo_code` varchar(250) NOT NULL,`cc_type` varchar(250) NOT NULL,primary key(id)); Combined the world falls apart. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/187232-sql-query-works-in-phpmyadmin-but-not-in-website/ Share on other sites More sharing options...
Adam Posted January 5, 2010 Share Posted January 5, 2010 That's exactly the problem, you cannot execute multiple queries from one mysql_query() call. PHPMyAdmin has a delimiter input that it uses to split the queries and execute one by one. Quote Link to comment https://forums.phpfreaks.com/topic/187232-sql-query-works-in-phpmyadmin-but-not-in-website/#findComment-988747 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.