title: How do I INSERT the character "&" into a MySQL database?
body: <p>I think I have seen this question before but I don't think it's answered good enough yet because I can't get it to work.</p>
  
  <p>The case: <br>
  I want to insert an URL into my MySQL database like so:</p>
  
  <pre><code>$url = $_POST["url"]; //$_POST["url"] = "http://example.com/?foo=1&amp;bar=2&amp; ...";
  
  $sql = mysql_query("INSERT INTO table(url) values('$url')") or die ("Error: " . mysql_error());
  </code></pre>
  
  <p>Now, the URL is inserted into the database properly but when I look at it, it looks like this:</p>
  
  <pre><code>http://example.com/?foo=1
  </code></pre>
  
  <p>It's like the URL is cut right at the "&amp;" character. I have tried: <code>mysql_real_escape_string</code>, <code>htmlspecialchars</code>, escaping by doing <code>"\"</code> etc. Nothing seems to work.</p>
  
  <p>I have read that you might be able to do it with "SQL Plus" or something like that.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Regards, VG</p>