INSERT into tbl_inquiry (name,phone,email,subject,message) values ('apoorva','000012345','email@email.com','subject','hi what's up')

Recommended Answers

All 4 Replies

Thats because of 'hi what's up'. It contains single quotes, '.You must escape ' or use double quotes.
like

using double quotes instead of single quote or vice versa if there is any one of them only in your data

INSERT INTO tbl_inquiry( name, phone, email, subject, message )
VALUES (
'apoorva', '000012345', 'email@email.com', 'subject', "hi what's up"  )

OR
using escape symbol

INSERT INTO tbl_inquiry( name, phone, email, subject, message )
VALUES (
'apoorva', '000012345', 'email@email.com', 'subject', 'hi what\'s up'
)

The reason why you can’t insert you input such as “hi what’s up” is because you used a single quote (‘hi what’s up’). Whenever you will use a single quote for your input, you need to use double quote (“hi what’s up”) because if not, the computer will think that the single quote you used for the word “what’s” is the partner of you first single quote that signifies your input and it will look for another partner for the left single quote and if it found nothing, that will result into a syntax error just like what happened to you.

Use:

INSERT into  tbl_inquiry (name,phone,email,subject,message) values ('apoorva', '000012345', 'email@email.com', 'subject', 'hi what's up');

Or you could replace the single quote in hi what's up with two single quotes as in hi what''s up.

example : INSERT into tbl_inquiry (name,phone,email,subject,message) VALUES ('apoorva', '000012345', 'email@email.com', 'subject', "hi what's up")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.