MYSQL / PHP Query Help

I have the following MYSQL Query:

Basically, the query will not work when i add quotes to the string. I want it to select from e-mails database where subject LIKE ‘%“SERVERNAME”%’

If I do just ‘%SERVERNAME%’ it works :S

I use the %strongservername to add the quotes.

$stringservername = “&quot$servername&quot”;
$stringjobname = “&quot$vjobname&quot”;

$queryemails = mysql_query(“SELECT * FROM emails WHERE subject like ‘$searchstatus’ AND subject like ‘%$stringservername%’ AND subject like ‘%$stringjobname%’ AND fromemail = ‘$matchfrom’”);

Any suggestions? :slight_smile:

Thankyou

No need to html encode double quotes in sql query, just escape them with backslash. This should work:

$queryemails = mysql_query("SELECT * FROM `emails` WHERE `subject` like '$searchstatus' AND `subject` like '%\"".$servername%."\"%' AND `subject` like '%\"".$vjobname."\"%' AND `fromemail` = '$matchfrom'");

Sponsor our Newsletter | Privacy Policy | Terms of Service