title: Textarea data sometimes does not insert into mysql database with copy and paste
body: <p>I've been having an issue that is difficult to pin-point, so I thought I'd ask the community about it. The issue is difficult to describe, because the odd user complains of a circumstance that I can't reproduce for the life of me, but it occurs consistently enough across enough users that I know it's real.</p>
  
  <p>Essentially, I have a site where users can post ads, there's a textarea where they can place up to 3000 characters of text, which is then posted to the db. The text is checked on submit by jquery for char length and the php post confirms this before anything else is processed. I don't use mysqli_real_escape_string because it messes up the users posts and makes them unhappy, so I clean the data with this function: </p>
  
  <pre><code>`function dataSecure($data){
      $data = trim($data);
      $data = stripslashes($data);
      $data = htmlspecialchars($data);
      $data = strip_tags($data);
      $data = addslashes($data);
      return $data;
  }`
  </code></pre>
  
  <p>before inserting with a prepared statement into the mysql database as a text, utf8-unicode-ci, default NULL. The function may seem overkill, but it prevents any type of SQL injection I'm able to come up with. If the script determines that the stmt was executed successfully, it deducts from the user's account, if not, in returns false and allows the user to edit the details.</p>
  
  <p>NOTE: The script works for 95% of all posts, the statement is prepared properly, etc., and is not posted here because the script isn't the issue. The issue arises when some users attempt to copy and paste their ad from either a word document or an e-mail into the text-area. In this case, the stmt is executed and the money is deducted from the user's account, but no data is actually inserted into the db. I have tried everything in my power to reproduce this error (using MSword documents, copying from their forwarded e-mails, adding odd characters, different browsers, using UFT8_encode() to prevent the error, etc.) but it doesn't work. Others have complained on SO of copy-and-pasted textareas failing to insert, but they appear to have remained unsolved. </p>
  
  <p>My best bet is that something in the textarea isn't jiving with the DB, so I'm hoping someone with experience can help shed some light on what the problem is.</p>