1

I am sorry if I sound noob but I need some help here. I cant figure out with this query:

    $query = "SELECT * FROM msgs WHERE read = 1 AND userid='{$uId}' AND
orderid='{$oId}'; ";

When I do a var_dump on the query result i get bool(false) but when I do the same without the read = 1 part it returns results correctly so I guess the problem is with the read = 1 part. Please help, the read field type is tinyint(1).

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Kha Kali
  • 169
  • 2
  • 13

1 Answers1

1

You need to use back-ticks in your query because you used reserved keyword read:-

$query = "SELECT * FROM `msgs` WHERE `read` = 1 AND `userid`='{$uId}' AND `orderid`='{$oId}'";

Note:- read is reserved keyword here, i added around others because its not easy to remember all reserved keywords so using back-ticks around column name is better approach.

Link for depth knowledge given by @chris85 :- https://dev.mysql.com/doc/refman/5.5/en/keywords.html

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98