我需要一个网站从商业虚拟主机移动到虚拟服务器在你的PHP脚本中添加该代码。我在Windows Server 2008的IIS中使用php和mysql。我通过执行以下操作解决了mysqli_connect问题。
- 我在php.ini文件中取消了注释extension = php_mysql.dll,extension = php_mysqli.dll和extension = php_pdo_mysql.dll。
在我的php文件中,我有一个包含mysqli_connect函数的_construct函数。这种运作良好,在Apache和Unix服务器上,但不是在IIS和Windows Server 2008以下是代码:
<?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.......
}
?>
注:值分配给$连接工作,我没有别的办法。这是至少12小时的互联网搜索和试错编码的结果。我是一个新手编码器。它可能不漂亮,但它的工作原理。我希望这有帮助。
可能重复http://stackoverflow.com/questions/8551398/call-to-undefined-function-mysql-connect – 2013-05-06 05:54:34
普利文的differnce的是,我没有访问php.ini – 2013-05-06 05:56:15
然后更改主机 – 2013-05-06 05:57:15