helloand
helloand

Reputation: 3

Getting MySQL Error #1064 when trying to insert data

I'm trying to follow a tutorial on this website, but when I try to insert the below statement I get the following 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 
'`INSERT INTO  login_admin (user_name, user_pass)
VALUES
(
‘admin’, SHA(‘a`' at line 7 
INSERT INTO login_admin (user_name, user_pass)
VALUES
(
‘swashata’, SHA(‘swashata’)
)
 
INSERT INTO login_admin (user_name, user_pass)
VALUES
(
‘admin’, SHA(‘admin’)
)

Upvotes: 0

Views: 92

Answers (1)

elixenide
elixenide

Reputation: 44851

You're trying to run two queries at once, not one. Each INSERT statement is a separate query. You have to separate queries with a delimiter (;).

In fact, unless you have some bad settings on your server (allowing multiple queries at once), you can't even do that and need to run them as two separate queries, or combine them using multiple VALUES lists.

Also, please note that you cannot use tick marks () to indicate a string value. You need to use single quotes (') instead.

The best approach is to rewrite your queries as:

INSERT INTO login_admin (`user_name`, `user_pass`) VALUES
( 'swashata', SHA('swashata') ),
( 'admin', SHA('admin') )

Finally, I really hope you aren't using SHA to generate passwords. That's not secure. Use PHP's built-in password functionality.

Upvotes: 1

Related Questions