I was required to move a website from a commercial web host to a virtual server. I am using php and mysql in IIS on Windows Server 2008. I solved the mysqli_connect problem by doing the following.
- I uncommented extension=php_mysql.dll, extension=php_mysqli.dll, and extension=php_pdo_mysql.dll in the php.ini file.
In my php file I had a class with a _construct function that included the mysqli_connect function. This works well in Apache and on the Unix server but not in IIS and Windows Server 2008. Here is the code:
<?php
class MyClass
{
var $tablename="t_table";
var $connection;
public function __construct() {
$this->connection = new MySQLi("host", "user", "password", "dbname", "port")or die("Error connecting " . mysqli_error($connection));
}
//functions that use $this->connection and $tablename are here.......
}
?>
Note: No other way of assigning a value to $connection worked for me. This is the result of at least 12 hours of internet searching and trial and error coding. I am a novice coder. It may not be pretty but it works. I hope this helps.