you forgot to properly concatenation of string it should be like
$sql = 'SELECT email_id FROM dealer WHERE dealerid="' . mysql_real_escape_string($id) . '"';
String Operators
your code will probably give you
Parse error: syntax error, unexpected T_VARIABLE on line bla
This is a syntax error, meaning that there is something in your code stopping it from being parsed correctly and therefore run.
What you should do is check carefully at the lines around where the error is for any simple mistakes
so make sure you enable at least E_PARSE
in your php.ini
. Parse errors should not exist in production scripts.
i always recommended to while coding
error_reporting(E_ALL);
error_reporting
Note
- Its not true that we are using
mysql_real_escape_string()
and we are completly safe form sql injection cheak this answer by @ircmaxell
- The entire
ext/mysql
PHP extension, which provides all functions named with the prefix mysql_, is officially deprecated as of PHP v5.5.0 and will be removed in the future. So use either PDO
or MySQLi
Good read
- The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
- PDO Tutorial for MySQL Developers