title: PHP mysql_real_escape_string is not working as expected
body: <p>I have a weird problem.</p>
  
  <p>I have a table which has a title field.<br>
  I am inserting values into this title field using <code>mysql_real_escape_string</code>. Inserting is working fine for values with single quotes.<br>
  Some other place I am doing a select using title filed in the where clause as below</p>
  
  <pre><code>SELECT * FROM table WHERE title=mysql_real_escape_string(Girish's Photo);
  </code></pre>
  
  <p>This query is returning empty result set even when I  inserted Girish's Photo.</p>
  
  <p>---- Editing to put some code</p>
  
  <pre><code>$photo_title=mysql_real_escape_string($_POST[photo_title]);&lt;br/&gt;
  $sql = "INSERT INTO photos values($id,'$photo_title');&lt;br/&gt;
  </code></pre>
  
  <p>using this from a form I have inserted <em>Girish's Photo</em> into photo_title. It worked fine.<br/>
  ...
  ..
  ..</p>
  
  <p>Then at some other place in PHP<br/></p>
  
  <pre><code>$title="Girish's Photo";
  $sql = "SELECT photo_id,photo_title FROM photos WHERE photo_title ='" . mysql_real_escape_string($title)."'" ;
  </code></pre>
  
  <p>But this query is returning empty result set.<br/></p>
  
  <p>Using phpMyAdmin, if I try to run the above query .. the result is empty. If I browse the table I see value Girish\'s Photo<br/>
  Now if I run the query on phpMyAdmin replacing where clause with where photo_title='Girish\''s Photo'  I am getting the record.<br/></p>