I’ve recently had to fix a website using old mysql way to query things , as you all noticed mysqli_query uses inverted options meaning  mysqli_query($linkfirst,$queryafter); as of mysql_query($queryfirst,$linksecond);

So here you have a mysql backward compatibility script , is not “nice” but it does the job!

The $link is taken from global .



CONSTANTS need to be defined for the connection !

"p:" is for persistent connection do not use if you don't need !




if (!$link) {
die('Could not connect: ' . mysqli_error($link));
else {

mysqli_select_db($link, DB_DATABASE) or die('Could not select database.');


function mysql_query($query,$connection=""){

global $link;

return mysqli_query($link, $query);


function mysql_fetch_row($res){

return mysqli_fetch_row($res);


function mysql_num_rows($res){

return mysqli_num_rows($res);


function mysql_real_escape_string($query,$connection=""){

global $link;

return mysqli_real_escape_string($link,$query);


function mysql_fetch_array($result){

return mysqli_fetch_array($result);


function mysql_fetch_object($result){

return mysqli_fetch_object($result);





Keep it real ,
Best Regards ,Alin Razvan
I'm a small fish in a big ocean , trying to make a difference and some waves while swimming my way through .

Leave a Reply

Your email address will not be published. Required fields are marked *