I am trying to install opencart-1.5.5.1 on my localhost. But i am getting an error after STEP3-CONFIGURATION. The error is
Notice: 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 '\'0\', zone_id int(11) NOT NULL DEFAULT \'0\', PRIMARY KEY
(address_id' at line 13 Error No: 1064
CREATE TABLE `oc_address` ( `address_id` int(11) NOT NULL AUTO_INCREMENT, `customer_id` int(11) NOT NULL, `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, `company` varchar(32) NOT NULL, `company_id` varchar(32) NOT NULL, `tax_id` varchar(32) NOT NULL, `address_1` varchar(128) NOT NULL, `address_2` varchar(128) NOT NULL, `city` varchar(128) NOT NULL, `postcode` varchar(10) NOT NULL, `country_id` int(11) NOT NULL DEFAULT \'0\', `zone_id` int(11) NOT NULL DEFAULT \'0\', PRIMARY KEY (`address_id`), KEY `customer_id` (`customer_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; in D:\wamp\www\vogue\system\database\mysql.php on line 50
Because probably You have magic_quotes_gpc directive turned On, thus all quotes and apostrophes gets escaped by auto adding of slashes...
In Your php.ini find the directive magic_quotes_gpc and set to Off.
Related
Error
Could not successfully run query (SELECT * FROM prior_approval WHERE id = \'187\') from DB:
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 '\'187\'' at line 2
PHP code:
$sql9 = "UPDATE prior_approval SET approved = 1, rejected = 0 WHERE id= '" . mysql_real_escape_string($app_id) . "'";
$result9 = mysql_query($sql9) or die(mysql_error());
The test MySQL version is 5.6 and the live version is 5.1. An error message on the ISP's control panel says that the mysql version should be updated.
I have used mysqli as well but that failed so I reverted to mysql
using mysqli code:
$app_id = $_SESSION['app_id'];
$conn = mysqli_connect('localhost',$username,$password,$database);
$sql9 = "UPDATE prior_approval SET approved = 1, rejected = 0 WHERE id= (?)";
$stmt = $conn->prepare($sql9);
$stmt->bind_param('i',$app_id);
$result9 = $stmt->execute();
Resulting error:
Could not successfully run query (SELECT * FROM prior_approval WHERE id = \'187\') from DB: 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 '\'187\'' at line 2
New error including vardump:
string(7) "\'187\'"
Could not successfully run query (SELECT * FROM prior_approval WHERE id = \'187\') from DB: 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 '\'187\'' at line 2
Table create:
CREATE TABLE IF NOT EXISTS `prior_approval` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`approv_id` int(6) DEFAULT NULL,
`dist_code` varchar(30) DEFAULT NULL,
`dealer_code` varchar(30) DEFAULT NULL,
`reporter` varchar(50) DEFAULT NULL,
`report_date` date DEFAULT NULL,
`job_kind` int(1) DEFAULT NULL,
`attach` int(1) DEFAULT NULL,
`reply` tinyint(1) DEFAULT NULL,
`engine_oil` int(1) DEFAULT NULL,
`nature_code` varchar(50) DEFAULT NULL,
`model` varchar(10) DEFAULT NULL,
`causal_code` varchar(50) DEFAULT NULL,
`part_code` varchar(20) DEFAULT NULL,
`part_descr` varchar(20) DEFAULT NULL,
`op_code` varchar(20) DEFAULT NULL,
`subject` varchar(50) DEFAULT NULL,
`reg_no_1` varchar(20) DEFAULT NULL,
`vin_1` varchar(17) DEFAULT NULL,
`engine_1` varchar(10) DEFAULT NULL,
`reg_date_1` date DEFAULT NULL,
`km_reading_1` varchar(10) DEFAULT NULL,
`repair_date_1` date DEFAULT NULL,
`repl_no_1` varchar(20) DEFAULT NULL,
`complaint_nature` varchar(1000) DEFAULT NULL,
`sub_repair` varchar(1000) DEFAULT NULL,
`corr_action` varchar(1000) DEFAULT NULL,
`act_result` varchar(1000) DEFAULT NULL,
`recommend` varchar(1000) DEFAULT NULL,
`compl_period` varchar(10) NOT NULL,
`compl_number` int(11) NOT NULL,
`compl_freq` int(11) NOT NULL,
`while_stopped` tinyint(1) NOT NULL,
`during_braking` tinyint(1) DEFAULT NULL,
`during_acc_coast` tinyint(1) DEFAULT NULL,
`during_forward_rev` tinyint(1) DEFAULT NULL,
`during_turn` tinyint(1) DEFAULT NULL,
`turn_speed` int(11) DEFAULT NULL,
`during_rough` tinyint(1) DEFAULT NULL,
`rough_gear` varchar(10) DEFAULT NULL,
`during_decl_incr` tinyint(1) DEFAULT NULL,
`during_any_speed` tinyint(1) DEFAULT NULL,
`during_decel_coast` tinyint(1) DEFAULT NULL,
`using_brake` tinyint(1) DEFAULT NULL,
`using_ac` tinyint(1) DEFAULT NULL,
`using_defog` tinyint(1) DEFAULT NULL,
`using_steer` tinyint(1) DEFAULT NULL,
`using_wwash` tinyint(1) DEFAULT NULL,
`using_starter` tinyint(1) DEFAULT NULL,
`using_clutch` tinyint(1) DEFAULT NULL,
`using_radio` tinyint(1) DEFAULT NULL,
`using_other` tinyint(1) DEFAULT NULL,
`engine_idle` tinyint(1) DEFAULT NULL,
`engine_hot` tinyint(1) DEFAULT NULL,
`engine_start` tinyint(1) DEFAULT NULL,
`engine_cold` tinyint(1) DEFAULT NULL,
`engine_warm_up` tinyint(1) DEFAULT NULL,
`vary_car_speed` tinyint(1) DEFAULT NULL,
`vary_engine_speed` tinyint(1) DEFAULT NULL,
`vary_load` tinyint(1) DEFAULT NULL,
`vary_trunk_load` tinyint(1) DEFAULT NULL,
`how_always` tinyint(1) DEFAULT NULL,
`how_after` tinyint(1) DEFAULT NULL,
`after_speed` int(11) DEFAULT NULL,
`attach1` varchar(100) DEFAULT NULL,
`attach2` varchar(100) DEFAULT NULL,
`attach3` varchar(100) DEFAULT NULL,
`date_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`approved` tinyint(1) NOT NULL,
`rejected` tinyint(1) DEFAULT NULL,
`rejected_reason` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=186 ;
I had to convert the $app_id string to integer like this:
//$app_id = $_SESSION['app_id'];
$remove[] = "'";
$remove[] = "\\";
$app_id = (int)str_replace($remove,"", $_SESSION['app_id']);
The later version of MySQL seems to convert automatically.
I am creating a dynamic table using mysql query table name should be unique that's why i have added user id to table name.
In Controller:
$last_id = $this->User->getLastInsertID();
//$table_name = 'hello_'.$last_id.'_tutors';
// debug($table_name);
$this->User->query("CREATE TABLE IF NOT EXISTS `post_`.$last_id.`_tutors` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`user_id` int(8) NOT NULL,
`tutor_name` varchar(50) NOT NULL,
`tutor_email` varchar(50) NOT NULL,
`tutor_number` varchar(50) NOT NULL,
`tutor_gender` varchar(50) NOT NULL,
`tutor_address` varchar(100) NOT NULL,
`city_id` int(11) NOT NULL,
`area_id` int(11) NOT NULL,
`matric` varchar(200) NOT NULL,
`inter` varchar(200) NOT NULL,
`graduation` varchar(200) NOT NULL,
`masters` varchar(200) NOT NULL,
`diploma` varchar(200) NOT NULL,
`other_education` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=67 ;
");
it gave syntax error like:
Syntax error or access violation: 1064 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 '.75._tutors ( tutor_name
varchar(50) NOT NULL, tutor_email var' at line 1
if anyone may help. Thanks in advance.
Try using
$this->User->query("CREATE TABLE IF NOT EXISTS `post_".$last_id."_tutors` (
I have been having this reoccurring problem when attempting to import a .sql file into MySQL, Here is what I get
ERROR
SQL Query:
CREATE TABLE `ADMINS` (
`id` int(11) NOT NULL auto_increment,
`client_id` varchar(80) NOT NULL default '',
`client_pw` varchar(16) default NULL,
`client_school` varchar(16) default NULL,
`client_expdate` date default '0000-00-00',
`client_fullname` varchar(50) default NULL,
`webinfo` mediumtext,
`webinfodate` date default NULL,
`LastUpdate` timestamp(14) NOT NULL,
`user_activation_key` varchar(60) default NULL,
`user_email` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
MySQL Said:
#1064 - 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 '(14) NOT NULL,
`user_activation_key` varchar(60) default NULL,
`user_email' at line 10
Timestamps don't have lengths. Change:
timestamp(14)
to
timestamp
The syntax is not correct, as pointed by John you do not need to the length for timestamp datatype. In addition type=myisam is deprecated and its engine=myisam now.
CREATE TABLE `ADMINS` (
`id` int(11) NOT NULL auto_increment,
`client_id` varchar(80) NOT NULL default '',
`client_pw` varchar(16) default NULL,
`client_school` varchar(16) default NULL,
`client_expdate` date default '0000-00-00',
`client_fullname` varchar(50) default NULL,
`webinfo` mediumtext,
`webinfodate` date default NULL,
`LastUpdate` timestamp NOT NULL,
`user_activation_key` varchar(60) default NULL,
`user_email` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`)
) engine=MyISAM AUTO_INCREMENT=2 ;
I am trying to create some tables on phpMyAdmin, but when I use the code below I am getting this error:
#1064 - 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 '(32) NOT NULL,
activated enum(0,1) NOT NULL,
PRIMARY KEY (id)
) E' at line 8
Here is my code:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`sign_up_date` date(32) NOT NULL,
`activated` enum(`0`,`1`) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=1atin1 AUTO_INCREMENT=1 ;
Try following code. I have resolved your mistakes in code
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`sign_up_date` date NOT NULL,
`activated` enum('0','1') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
DATE data type takes no length
`sign_up_date` DATE NOT NULL
I have a very strange problem here. I am exporting a query through phpmyadmin and then when I run it using mysql_query I get an error saying that syntax of the query isn't correct.
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 `wp_cfs_events` ( `event_id` int(11) NOT NULL AUTO_' at line 14
The same query runs perfectly fine using phpmyadmin. What could be the problem?
Here is the SQL query
CREATE TABLE IF NOT EXISTS `wp_cfs_certificates` (
`certificate_id` varchar(8) DEFAULT NULL,
`parent_name` varchar(45) NOT NULL,
`address` varchar(45) NOT NULL,
`phone_number` varchar(15) NOT NULL,
`emergency_number` varchar(15) NOT NULL,
`email` varchar(45) NOT NULL,
`certificate_price` enum('40','50') NOT NULL,
`certificate_order_time` datetime DEFAULT NULL,
`is_used` tinyint(1) DEFAULT '0',
UNIQUE KEY `certificate_id_UNIQUE` (`certificate_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `wp_cfs_events` (
`event_id` int(11) NOT NULL AUTO_INCREMENT,
`event_name` varchar(60) DEFAULT NULL,
`event_desc` varchar(2048) DEFAULT NULL,
`event_date` date DEFAULT NULL,
PRIMARY KEY (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
INSERT INTO `wp_cfs_events` (`event_id`, `event_name`, `event_desc`, `event_date`) VALUES
(1, 'Culture Night', 'all about culture', '2013-05-16'),
(2, 'Sports Night', 'all about sports', '2013-05-31'),
(3, 'Random Night', 'randomness overloaded', '2013-06-15'),
(4, 'Winter Fest', 'the awesome winter fest', '2013-11-20'),
(5, 'Archived Event', 'this event has been occured in past', '2013-04-02');
CREATE TABLE IF NOT EXISTS `wp_cfs_parents` (
`parent_id` int(11) NOT NULL,
`parent_name` varchar(60) DEFAULT NULL,
PRIMARY KEY (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `wp_cfs_registrations` (
`registration_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`certificate_id` varchar(8) NOT NULL,
`event_id` varchar(45) DEFAULT NULL,
`parent_name` varchar(45) NOT NULL,
`address` varchar(45) NOT NULL,
`phone_number` varchar(15) NOT NULL,
`emergency_number` varchar(15) NOT NULL,
`email` varchar(45) NOT NULL,
`child_name` varchar(45) DEFAULT NULL,
`child_age` int(11) DEFAULT NULL,
PRIMARY KEY (`registration_id`),
UNIQUE KEY `certificate_id_UNIQUE` (`certificate_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
ALTER TABLE `wp_cfs_registrations`
ADD CONSTRAINT `certificate_id` FOREIGN KEY (`certificate_id`) REFERENCES `wp_cfs_certificates` (`certificate_id`) ON DELETE NO ACTION ON UPDATE CASCADE;
Its because mysql_query() doesn't support multiple queries
Its mentioned in the official PHP documentation
mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.