Jump to content

SQL Query works in phpmyadmin but not in website.


Perad

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.