I want to import an SQL file to my phpMyAdmin database, the file contains tables about a restaurant application and a table about the admin login, but I have 2 unexpected errors, I really don't see what is exactly wrong with that?. here is the error message:
2 errors were found during analysis.
An opening bracket followed by a set of values was expected. (near "CREATE" at position 109)
Unexpected token. (near "CREATE" at position 109)
SQL query:
INSERT INTO `adminlogin` (`id`, `Username`, `Password`, `right`) VALUES (1, 'admin#gmail.com', '123', 1), CREATE TABLE IF NOT EXISTS `tbl_food` ( `id` int(11) NOT NULL AUTO_INCREMENT, `food_type` varchar(50) NOT NULL, `food_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE TABLE IF NOT EXISTS `tbl_food` (
`id` int(11) NOT NULL AUTO_INCREMENT,
' at line 6
and here is the two tables that show errors. Any insight on that? thank you
CREATE TABLE IF NOT EXISTS `adminlogin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Username` varchar(100) NOT NULL,
`Password` varchar(50) NOT NULL,
`right` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `adminlogin`
--
INSERT INTO `adminlogin` (`id`, `Username`, `Password`, `right`) VALUES
(1, 'admin#gmail.com', '123', 1),
-- --------------------------------------------------------
--
-- Table structure for table `tbl_food`
--
CREATE TABLE IF NOT EXISTS `tbl_food` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`food_type` varchar(50) NOT NULL,
`food_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
You have a comma at the end of INSERT statement, instead of semicolon.
Related
I want to import an SQL file to my phpMyAdmin database, the file contains tables about a restaurant application and a table about the admin login, but I have 2 unexpected errors, I really don't see what is exactly wrong with that?. here is the error message:
Static analysis:
2 errors were found during analysis.
An opening bracket followed by a set of values was expected. (near "CREATE" at position 285)
Unexpected token. (near "CREATE" at position 285)
SQL query:
-- -- Déchargement des données de la table `operation` --
INSERT INTO `operation` (`numop`, `numcp`, `prenom`, `nom`, `type`, `numcp2`, `mentant`, `date`) VALUES
-- -------------------------------------------------------- --
-- Structure de la table `reclamation` --
CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL
,`id` varchar(8) NOT NULL
,`prenom` varchar(30) NOT NULL
,`nom` varchar(30) NOT NULL
,`text` text NOT NULL
,`date` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
MySQL said: Documentation
#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 'CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL,
`id` varchar(8) NO' at line 14
CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL,
`id` varchar(8) NOT NULL,
`prenom` varchar(30) NOT NULL,
`nom` varchar(30) NOT NULL,
`text` text NOT NULL,
`date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
There are no values after VALUES in operation insertion query.
This error points on create because this is the next to the insertion and it expected to be values but actually is CREATE ...
It seems the values cutted off, make sure to separate between queries with ;
INSERT INTO `operation` (`numop`, `numcp`, `prenom`, `nom`, `type`, `numcp2`, `mentant`, `date`) VALUES
-- Structure de la table reclamation --
CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL
,`id` varchar(8) NOT NULL
,`prenom` varchar(30) NOT NULL
,`nom` varchar(30) NOT NULL
,`text` text NOT NULL
,`date` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
Having this table using mysql 5.7:
CREATE TABLE `emails` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`subject` varchar(191) COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
When I try to insert some emojis:
INSERT INTO `emails` (`from_address`, `subject`) VALUES (1, 'A😀B C👨🏽🎨D')
I receive:
Incorrect string value: '\xF0\x9F\x98\x80B ...' for column 'subject' at row 1
Why? if i'm using utfmb?
Is your connection also utf8mb4? Detailed explanation of this can be found at: https://mathiasbynens.be/notes/mysql-utf8mb4
After i used the new answer i uploaded the file and this is what i get now.
SQL query:
CREATE TABLE IF NOT EXISTS `games` ( ) INSERT INTO `games` (`name`, `creatorid`, `gameid`, `id`, `plays) VALUES ('בדיקה', 'לא ידוע', 1,1,0) CREATE TABLE IF NOT EXISTS `gamewall` ( `userid` int(11) NOT NULL, `reason` text NOT NULL, `comment` text NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `bannedbyid` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE IF NOT EXISTS `bans_IP` ( `IP` mediumtext NOT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `bannerid` int(11) NOT NULL, `reason` mediumtext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; CREATE TABLE IF NOT EXISTS `buysell` ( `buysell` int(11) NOT NULL, `sellerid` int(11) NOT NULL, `price` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE IF NOT EXISTS `competitions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` mediumtext NOT NULL, `startedbyid` int(11) NOT NULL, `descripti[...]
MySQL said: Documentation
#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 ')
INSERT INTO `games` (`name`, `creatorid`, `gameid`, `id`, `plays) VALUES
('' at line 3
You are receiving this error because you have selected all the columns of your table but values are available for first 11 columns and you missed ) in last
This code will fix your problem
INSERT INTO `accounts` (
`Username`,
`Password`,
`Email`,
`salt`,
`Reebs`,
`online`,
`lastOnline`,
`lastOnlineMinutes`,
`lastOnlineHours`,
`status`,
`blurb`
)
VALUES
(
'AvatarLife',
'df3ed1ad53c4cc2f3b5c6bdf04d33a9f094df53b',
'fawrsnipng#gmail.com',
'jBqnW?Dk9Epzpg4',
'9223372036854775807',
'1',
'205',
'26',
'13',
'',
'Avatar Life is the only good life!')
I am trying to add an addon to my game here, and i need to add this query to the mysql, query is below:
CREATE TABLE `streets` (
`id` int(11) NOT NULL auto_increment,
`min_level` int(11) NOT NULL,
`text` longtext NOT NULL,
`query` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MYISAM ;
INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES ('NULL', 'steps_daily', '100')
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
When i try to enter the query into sql i get this error:
Error
SQL query:
INSERT INTO `settings` ( `conf_id` , `conf_name` , `conf_value` )
VALUES (
'NULL', 'steps_daily', '100'
)
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
MySQL said: Documentation
#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 'ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL' at line 3
You forgot a ; after your INSERT INTO query.
CREATE TABLE `streets` (
`id` int(11) NOT NULL auto_increment,
`min_level` int(11) NOT NULL,
`text` longtext NOT NULL,
`query` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MYISAM ;
INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES
(NULL, 'steps_daily', '100');
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
P.S.: NULL should not be in quotes. You want the value NULL, not the literall string ,'NULL'.
Do not use quotes for NULL and then try.
INSERT INTO `settings` ( `conf_id` , `conf_name` , `conf_value` )
VALUES (NULL, 'steps_daily', '100');
So I'm a complete novice with MySQL and I'm trying to follow a tutorial that will allow me to sort out an Ajax + JQuery page for my database.
However, running this code in PHPMyAdmin:
CREATE TABLE IF NOT EXISTS 'add_delete_record' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'content' text NOT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
produces the error:
SQL query:
CREATE TABLE IF NOT EXISTS 'add_delete_record'(
'id'INT( 11 ) NOT NULL AUTO_INCREMENT , 'content'TEXT NOT NULL ,
PRIMARY KEY ( 'id' ) ) ENGINE = INNODB DEFAULT CHARSET = latin1
AUTO_INCREMENT =1 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 ''add_delete_record' ( 'id' int(11) NOT NULL AUTO_INCREMENT,
'content' text' at line 1
Being a novice I have absolutely no clue what is wrong, apart from the fact that there is a problem with the syntax somewhere? Thanks to anyone who can help!
Use backticks instead. Single quotes represent string literals.
CREATE TABLE IF NOT EXISTS `add_delete_record` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
use backticks
CREATE TABLE IF NOT EXISTS `add_delete_record` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;