mysql_real_escape_string escapes but does not quote.
Try:
$sQuery=mysql_query("select * from tbl_mini_website as s1, tbl_actor_merchant as me where s1.MERCHANT_ID='$ID' AND s1.MERCHANT_ID=me.MERCHANT_ID");
More generally, I tend to wrap both of them in a function, for example:
function quoteValue($value) { return "'" . mysql_real_escape_string($value) . "'"; }
This is useful because you can find a line where you want to improve the behavior of quotes (especially when it comes to handling Unicode, control characters, etc.).
source share