title: PHP script returns null when inserting <a> into database
body: <p>I have a basic CMS where a user can update a database of articles and it uses a simple set of BBCodes for some extra features.</p>
  
  <p>Basically, the user inputs the article information into a HTML form, and then on the click of a "Publish" button, an AJAX request is sent to a PHP script on the server which uses Regex to convert the BBCodes to HTML, and then stores the info in the database using MySQL.</p>
  
  <p>My problem is an unfortunate one, in that it has come immediately after solving another, and it is very hard to debug since it is a server side script and I am getting no error messages echoed at all.</p>
  
  <p>I was having trouble with the Regex, specifically with more complicated tags. I managed to get [link=URL]FOOBAR[/link] tags to correctly match and then replace them with FOOBAR. For some reason, however, this now made the script either hang or fail or something because I'm not getting anything updated into the database when it contains [link] tags.</p>
  
  <p>For the purposes of debugging earlier when I wanted to get the SQL working, I had the PHP script echo the return value of the mysql_query() function which I believe is a "1" when it is successful, and a "0" when it fails. Now, however, it simply returns nothing... and the HTTPRequest receives a 0 length string back.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>$post = $_POST['post'];
  $regex = Array('#(\r?\n)#', '#(\[(\/?)(b|i|u)\])#', '#\[link=(http://(www.)?.*?)\](.*?)\[/link\]#', '#(\[youtube\][http://www.youtube.com/watch?v=]?(\w+)[&amp;\w+]?\[/youtube\])#', '#(\[img\](http://[www.]?[\w+])\[/img\])#');
  $regReplace = Array('&lt;br /&gt;', '&lt;$2$3&gt;', '&lt;a href="$1"&gt;$3&lt;/a&gt;', '&lt;div class="media"&gt;&lt;iframe title="YouTube video player" width="560" height="315" src="http://www.youtube.com/embed/$2" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;',
                  '&lt;div class="media"&gt;&lt;img width="560" src="$2" /&gt;&lt;/div&gt;');
  $post = preg_replace($regex, $regReplace, $post);
  echo mysql_query('INSERT INTO News VALUES (NULL, "'.Date('D jS M').'", "'.Date('G:i').'", "'.$_POST['heading'].'", "'.$post.'")');
  </code></pre>
  
  <p>I am aware that the IMG and Youtube regexs don't work...</p>