title: percent sign in PHP string
body: <p>I want to fire a query on database:</p>
  
  <pre><code>$query="SELECT field1 from table_name where field2 like '%".$_REQUEST['var1']."%'";
  </code></pre>
  
  <p>Page is showing <strong>500 internal server error</strong>.</p>
  
  <p>At the time of debugging, I echo <em>$query</em>.
  It was like:</p>
  
  <pre><code>SELECT field1 from table_name where field2 like 'value_of_var1%'
  </code></pre>
  
  <p>Where does the first percent sign has gone?
  I searched on internet some said i have to put double percent sign(%%) in order to escape percent sign. If so, then why does the second percent sign doesn't need to be escaped?</p>
  
  <p>This code(query) is executing in AJAX page, in order to debug i opened that AJAX page via URL.
  It is showing perfect result</p>
  
  <pre><code>SELECT field1 from table_name where field2 like '%value_of_var1%'
  </code></pre>
  
  <p>But when page is called via AJAX it showing without first percent sign.
  Can you please help me to understand what really the problem is?</p>