I recently upgraded my server and now I'm trying to convert everything from MySQL to MySQLi and I'm having some difficulty.
I keep getting this error:
PHP Warning: mysqli_select_db() expects exactly 2 parameters
Can someone guide me in the right direction please and thanks!!!
Here is my old code that is in a PHP class:
class Db {
function __construct($app = ''){
// Get the main settings from the array we just loaded
$host = 'localhost';
$user = 'username';
$pass = 'password';
$db = 'db_name';
// Connect to the database
$this->link = mysqli_connect($host, $user, $pass);
mysqli_select_db($db);
register_shutdown_function(array(&$this, 'close'));
}
function query($query){
if($query) return @mysqli_query($query, $this->link);
else return false;
}
function fetchArray($result){
if($result) return mysqli_fetch_array($result, mysqli_ASSOC);
else return false;
}
function queryFetch($query){
if($query) $result = mysqli_query($query, $this->link);
if($result)
return mysqli_fetch_array($result, mysqli_ASSOC);
else
return false;
}
function close(){
mysqli_close($this->link);
}
}