To add to Erel's comment, your code example also allows for SQL Injection and other fun things. Not only is no encoding or escaping of values done, but there is the assumption that most of the values exist too. Depending on server config you may even have to strip out extra things in older versions that was added to aid those not encoding and escaping their data to prevent injections:
if (get_magic_quotes_gpc() == 1) {
foreach ($_POST as &$value) $value = stripslashes($value);
foreach ($_GET as &$value) $value = stripslashes($value);
}
With the assumptions of values existing and such too you may also be getting error/warning text back causing issues if reporting of them isn't off.
I actually prefer the mysqli library in PHP too which gives even better options and allows for providing SQL Parameters to prevent injection. Lots of "or die" lines in the code too. I usually properly handle errors and close things/free results to not have issues, even if the documentation claims it is done for you.