0

4 errors were found during analysis.

Ending quote ' was expected. (near "" at position 510)

A comma or a closing bracket was expected. (near "', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default ‘0'" at position 181)

Unexpected beginning of statement. (near "20" at position 268)

Unrecognized statement type. (near "NOT NULL" at position 272)

SQL query:

CREATE TABLE IF NOT EXISTS `users`
(
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `password` varchar(32) NOT NULL,
  `online` int(20) NOT NULL default ‘0',
  `email` varchar(100) NOT NULL,
  `active` int(1) NOT NULL default ‘0',
  `rtime` int(20) NOT NULL default ‘0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; 

INSERT INTO `users` (`id`, `username`, `password`, `online`, `email`, `active`, `rtime`) 
VALUES (1, ‘testing’, ‘testing’, 0, ‘[email protected]’, 0, 0); 
1
  • You have curly single quotes in the question. Commented Jul 9, 2016 at 12:56

6 Answers 6

2

You use a different kind of quote character for instance

`online` int(20) NOT NULL default ‘0', 
         here --------------------^

Replace it with a normal one every time you use it

CREATE TABLE IF NOT EXISTS `users`
(
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `password` varchar(32) NOT NULL,
  `online` int(20) NOT NULL default '0',
  `email` varchar(100) NOT NULL,
  `active` int(1) NOT NULL default '0',
  `rtime` int(20) NOT NULL default '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; 

But since the type of those columns is int you don't need quotes around the default values at all.

Sign up to request clarification or add additional context in comments.

1 Comment

Those columns are INTEGERs, thus there's no need for quotes at all.
1

Just remove '' quotes from 0 for all Int datatype.

CREATE TABLE IF NOT EXISTS users ( id int(11) NOT NULL auto_increment, username varchar(32) NOT NULL, password varchar(32) NOT NULL, online int(20) NOT NULL default 0, email varchar(100) NOT NULL, active int(1) NOT NULL default 0, rtime int(20) NOT NULL default 0, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Comments

0

You are using different types of quotes together ' with

Replace this:

CREATE TABLE IF NOT EXISTS `users`
(
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `password` varchar(32) NOT NULL,
  `online` int(20) NOT NULL default ‘0',
  `email` varchar(100) NOT NULL,
  `active` int(1) NOT NULL default ‘0',
  `rtime` int(20) NOT NULL default ‘0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; 

INSERT INTO `users` (`id`, `username`, `password`, `online`, `email`, `active`, `rtime`) 
VALUES (1, ‘testing’, ‘testing’, 0, ‘[email protected]’, 0, 0);

With this:

CREATE TABLE IF NOT EXISTS `users`
(
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `password` varchar(32) NOT NULL,
  `online` int(20) NOT NULL default '0',
  `email` varchar(100) NOT NULL,
  `active` int(1) NOT NULL default '0',
  `rtime` int(20) NOT NULL default '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;



INSERT INTO `users` (`id`, `username`, `password`, `online`, `email`, `active`, `rtime`) 
VALUES (1, 'testing', 'testing', 0, '[email protected]', 0, 0); 

Comments

0

Try this:

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(32) NOT NULL,
  `password` varchar(32) NOT NULL,
  `online` int(20) NOT NULL DEFAULT '0',
  `email` varchar(100) NOT NULL,
  `active` int(1) NOT NULL DEFAULT '0',
  `rtime` int(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

And:

INSERT INTO users (id, username, password, online, email, active, rtime) VALUES (1, 'testing', 'testing', 0, '[email protected]', 0, 0);

Comments

0

Sql Executed

Please correctly select the Database first:

Copy the below given SQL in the SQL editor and execute it. Hope this solves your problem. Thanks.

CREATE TABLE IF NOT EXISTS `users`
(
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `password` varchar(32) NOT NULL,
  `online` int(20) NOT NULL default '0',
  `email` varchar(100) NOT NULL,
  `active` int(1) NOT NULL default '0',
  `rtime` int(20) NOT NULL default '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; 

INSERT INTO `users` (`id`, `username`, `password`, `online`, `email`, `active`, `rtime`) 
VALUES (1, 'testing', 'testing', 0, '[email protected]', 0, 0);

Comments

0
  • No need of any quote around the default value zero

  • You need to replace the single quote ' instead of the , quotes in the INSERT query.

The working code will be

CREATE TABLE IF NOT EXISTS `users` (
  `id`       int(11)      NOT NULL auto_increment,
  `username` varchar(32)  NOT NULL, 
  `password` varchar(32)  NOT NULL, 
  `online`   int(20)      NOT NULL default 0, -- here
  `email`    varchar(100) NOT NULL, 
  `active`   int(1)       NOT NULL default 0, -- here
  `rtime`    int(20)      NOT NULL default 0, -- here
  PRIMARY KEY (`id`) 
) ENGINE = MyISAM DEFAULT CHARSET=utf8; 

INSERT INTO `users` (`id`, `username`, `password`, `online`, `email`, `active`, `rtime`) 
VALUES (1, 'testing', 'testing', 0, '[email protected]', 0, 0); -- here

SQL Fiddle DEMO: http://sqlfiddle.com/#!9/286728/1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.