title: mysql_real_escape_string strange apostrophe behaviour?
body: <p>I have a form and a user enters eg (note apostrophe at end of string)</p>
  
  <pre><code>My Bday'
  </code></pre>
  
  <p>Now, I want to strip apostrophes, simple as that... not escape them, not add slashes just get rid of them</p>
  
  <p>Firstly I have the following:</p>
  
  <pre><code>$event_title = mysql_real_escape_string($_POST['event_title']);
  
  echo "&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;event title is $event_title";
  </code></pre>
  
  <p>Which results in the following being returned:</p>
  
  <pre><code>event title is My Bday\\\'
  </code></pre>
  
  <p>Why 3 slashes?</p>
  
  <p>So, then I go ahead and deal with this by using the following:</p>
  
  <pre><code>$event_title = str_replace("'", "", $event_title); 
  
  $event_title = stripslashes($event_title); 
  </code></pre>
  
  <p>Then I return it again to check results</p>
  
  <pre><code>echo "&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;event title is $event_title";
  </code></pre>
  
  <p>I get the following:</p>
  
  <pre><code>event title is My Bday\
  </code></pre>
  
  <p>Any ideas what's happening? I simply want to strip apostophes and slashes but somehow it's not happening</p>
  
  <p>magic_quotes_gpc is off by the way</p>
  
  <p>If I don't use stripslashes therefore leaving them in for MySQL to deal with I get the following error:</p>
  
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your
  MySQL server version for the right syntax to use near 'Private',
  event_notes = '' where user_event_id = '35'' at line 3
  
  update user_events set event_date = '2012-11-17', event_title = 'My Bday\\\',
  event_vis = 'Private', event_notes = '' where user_event_id = '35'
  </code></pre>
  
  <p>OK, a further EDIT:</p>
  
  <p>I tried this:</p>
  
  <pre><code>$event_title = $_POST['event_title'];
  
  $event_title = str_replace("'", "", $event_title);
  
  $event_title = trim($event_title);
  
  $event_title = mysql_real_escape_string($event_title);
  
  echo "&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;event title is $event_title";
  </code></pre>
  
  <p>and I get this:</p>
  
  <pre><code>event title is My Bday\\
  </code></pre>
  
  <p>I simply want to get rid of apostrophes, clearly something else is going on here but its got me!</p>