PHP mysql returns null, hard coded SQL query works <p>I'm having an issue in which I'm unable to get my database query within a PHP program to work. The query works fine within the program if it is hard coded, but it fails otherwise and passes back no results. I have echo'd the two results and am given a different string length, but the string I am given is identical (strings gotten via var_dump). I'm at my wit's end; I'm not really sure what is the issue with the query. I have tried several different fixes which I found for similar problems, but none of them have worked. I trim the posted input and also have the variable double quoted as opposed to single quoted so that the reference executes. I really just have no clue what's wrong. Here is the code that's relevant to this project: AJAX call to php class:</p> <pre><code>chlorinator = ($('#chlorinator').val()).concat(' GS').trim(); $.ajax( { type: "POST", url: "gravity.php", data: "chlorinator="+chlorinator, cache: false, beforeSend: function () { $('#results').html('&lt;img src="loader.gif" alt="" width="24" height="24"&gt;'); }, success: function(html) { $("#results").html( html ); }}); </code></pre> <p>And here is the relevant php code:</p> <pre><code>&lt;?php include 'connection.php'; $chlorinator = trim( mysqli_real_escape_string ($dbhandle,$_POST["chlorinator"])); $query = 'SELECT chlorinators.model_name, equipment.name, equipment.cutsheet_url, chlorinators.pump_specific, equipment.file_name FROM chlorinators INNER JOIN chlorinator_equipment ON chlorinators.chlorinator_index = chlorinator_equipment.chlorinator_index INNER JOIN equipment ON chlorinator_equipment.equipment_index = equipment.equipment_index WHERE chlorinators.model_name= "' . $chlorinator . '"'; echo "The value of the combined string is:&lt;br&gt; "; var_dump($query); echo '&lt;br&gt;&lt;br&gt;'; echo "The value of the hard-coded string is:&lt;br&gt; "; $query = 'SELECT chlorinators.model_name, equipment.name, equipment.cutsheet_url, chlorinators.pump_specific, equipment.file_name FROM chlorinators INNER JOIN chlorinator_equipment ON chlorinators.chlorinator_index = chlorinator_equipment.chlorinator_index INNER JOIN equipment ON chlorinator_equipment.equipment_index = equipment.equipment_index WHERE chlorinators.model_name= "2075 GS"'; var_dump($query); echo '&lt;br&gt;&lt;br&gt;'; if ($result = $dbhandle-&gt;query($query)) {?&gt; &lt;br&gt;&lt;br&gt;&lt;?php var_dump($result-&gt;fetch_assoc()); printf("&lt;p style='font-family:sans-serif; text-align: center;'&gt;The components of the %s are listed below&lt;/p&gt;&lt;table id='form' name='pump' style='margin: auto; padding: auto'&gt;", $_POST["chlorinator"]); while($row = $result-&gt;fetch_assoc()) { printf ("&lt;div&gt;&lt;tr&gt;&lt;td&gt;%s&lt;/td&gt;&lt;td&gt;&lt;a href='%s' download&gt;Download&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;", $row["name"],$row["cutsheet_url"]); } printf('&lt;/table&gt;'); } ?&gt; </code></pre> <p>For this particular example I'm using the value '2075 GS' as the chlorinator value. It is generally passed via change on a selection box, so the values are hard coded and correct. The output of this specific example is:</p> <blockquote> <p>string(403) "SELECT chlorinators.model_name, equipment.name, equipment.cutsheet_url, chlorinators.pump_specific, equipment.file_name FROM chlorinators INNER JOIN chlorinator_equipment ON chlorinators.chlorinator_index = chlorinator_equipment.chlorinator_index INNER JOIN equipment ON chlorinator_equipment.equipment_index = equipment.equipment_index WHERE chlorinators.model_name= "2075 GS""</p> <p>string(404) "SELECT chlorinators.model_name, equipment.name, equipment.cutsheet_url, chlorinators.pump_specific, equipment.file_name FROM chlorinators INNER JOIN chlorinator_equipment ON chlorinators.chlorinator_index = chlorinator_equipment.chlorinator_index INNER JOIN equipment ON chlorinator_equipment.equipment_index = equipment.equipment_index WHERE chlorinators.model_name= "2075 GS""</p> </blockquote> <p>I don't see any difference between the two outputs; any idea as to where the one character difference is and how I can eliminate it so that my query will properly work? Any help is greatly appreciated.</p>