Mehman Manafov
Mehman Manafov

Reputation: 449

What is the error in the following mysql statement?

"INSERT INTO messages (idR,idS,nameS,message,read) VALUES     ($id,'$_SESSION[id]','$myname','$message',1)";

It says you have mysql error syntax near'read) VALUES ($id,'$_SESSION[id]','$myname','$message',1)'

Upvotes: 0

Views: 30

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269743

The word read is a reserved word. Put it in backquotes:

INSERT INTO messages (idR, idS, nameS, message, `read`)
    VALUES ($id, '$_SESSION[id]', '$myname', '$message', 1)

Here is the list of MySQL reserved words.

Upvotes: 2

Related Questions