w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
phpmyadmin mysql INSERT statement syntax error

The string value you're inserting into the email filed needs to be quoted. Also, the names of the table and columns shouldn't be quoted. The query should look like this:

INSERT INTO members (username, password, fname, email,
contactnum)
VALUES (2, 2, 2, 'have@gmail.com', 1)

Note that the first three fields you're changing are declared as varchar, so you should be inserting strings into them as well. The reason you're not getting errors for trying to insert integers into varchar fields is that in some cases the wrong data type can be automatically converted. I think it's better practice not to rely on implicit type conversions, to avoid errors and unexpected results, so the query really should be written this way:

INSERT INTO members (username, password, fname, email,
contactnum)
VALUES ('2', '2', '2', 'have@gmail.com', 1)

That's a matter of opinion, though. They both work.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.