title: Ajax response not working when mysql_query has "AND" in it
body: <p>so this is my problems short version:</p>
  
  <p><strong>This works:</strong></p>
  
  <pre><code>$query = mysql_query("SELECT * FROM `some_table` 
                       WHERE IF (LENGTH('$some_variable') &gt; 0, `$other_variable` LIKE
                                 '%$some_variable%' , 0)");
  </code></pre>
  
  <p>I get a result go through it with a while pack it all in an array and with json_encode send it back to my ajax file, where i list the result. And it works perfectly.</p>
  
  <p>But when i ad one more thing to the query it just gives back empty, so <strong>this doesn't work:</strong></p>
  
  <pre><code>$query = mysql_query("SELECT * 
                        FROM `some_table` 
                        WHERE `something` = `some_other_thing` AND 
                            IF (LENGTH('$some_variable') &gt; 0, `$other_variable` 
                                 LIKE '%$some_variable%' , 0)");
  </code></pre>
  
  <p>So with that <strong>AND</strong> things just don't work, but only whit ajax, i mean if i simply print the array out php works superbly.</p>
  
  <p>Thanks in advance.</p>
  
  <p>This is the rest of my php</p>
  
  <pre><code>while ($value = mysql_fetch_array($query)) {
  
  $result[] = array
              (       
                  gyarto =&gt; $value['gyarto'],
                  termekcsalad =&gt; $value['termekcsalad'],
                  kiszereles =&gt; $value['kiszereles']
              );
  }
  
  echo json_encode($result);
  </code></pre>
  
  <p>and my jquery:</p>
  
  <pre><code>$.ajax({
                      url:"updates/isu.php",
                      type:"POST",
                      data: form,
                      dataType: "json",
                      success: function(data) {
  
  
                      $.each(data, function(i)                            
                      {
                         $("#result table").append('&lt;tr&gt;&lt;td&gt;'+data[i].gyarto+' '+data[i].termekcsalad+' '+data[i].kiszereles+'&lt;/td&gt;&lt;/tr&gt;');
  
                      }); 
  
                  }
              });
  
          });
  </code></pre>