title: How to handle (on the server side) ampersand while inserting text into MySQL using PHP?
body: <p>When we insert a string with ampersand character into mysql, the string is inserted only till &amp; character is encountered.</p>
  
  <p>Example: when inserting "one &amp; two"... only "one " is inserted.</p>
  
  <p>Tried a few things like... htmlentities OR htmlspecialchars... nothing working for me.</p>
  
  <p>Current PHP code:</p>
  
  <pre><code>$sms = htmlentities($_POST["sms"]);
  
  
  $query = "INSERT INTO sms (detail,catID,deviceID) VALUES ('".$sms."',".$_POST["catID"].",'".$_POST["deviceID"]."')";
  </code></pre>
  
  <p>And as the app is live... I need to resolve it by editing the PHP files only, on the server. (I hope it can be done)</p>