You should move to the MySQLi (MySQL Improved/php5-mysqlnd) extension instead for PHP. Other than needing an explicit database link (so you need to save your mysqli_connect() to a variable, then do mysqli_query($dbLink, $query); ). It also has built in, good support for stuff like prepared...