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 .

<?php 

/*

CONSTANTS need to be defined for the connection !

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

*/

$link = mysqli_connect("p:".DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE,3306);

#var_dump($link->client_info);

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 .