Reputation: 37
I have the fallowing code :
$query = "SELECT `email` FROM `user` WHERE `email` = " . mysql_real_escape_string($this->email) . "";
I don't know what kind of quotation marks should i use, because it doesn't work.
Upvotes: 0
Views: 534
Reputation: 13535
There are many ways to construct queries. You have chosen a raw approach which is legal, but the extension your using is marked depricated. I suggest looking into mysqli
and PDO.
For your answer.
$query = "SELECT `email` FROM `user` "
. "WHERE `email` = '" . mysql_real_escape_string($this->email) . "'";
Upvotes: 0
Reputation: 944054
None, instead you should use a placeholder and then allow the database library / server to handle the escaping and quoting of your data (as described in How to prevent SQL injection in PHP?).
Upvotes: 1
Reputation: 1763
$query = "SELECT `email` FROM `user` WHERE `email` = " . mysql_real_escape_string($this->email) . "";
should be
$query = "SELECT `email` FROM `user` WHERE `email` = '" . mysql_real_escape_string($this->email) . "'";
Upvotes: 0
Reputation: 28753
Try with single quotes('')
$query = "SELECT `email` FROM `user` WHERE `email` = '" . mysql_real_escape_string($this->email) . "'";
Upvotes: 0
Reputation: 19889
Single quotes should be used:
$query = "SELECT `email` FROM `user` WHERE `email` = '" . mysql_real_escape_string($this->email) . "'";
Upvotes: 2