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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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