所以这是错误信息:
PHP不推荐使用:mysql_connect():不推荐使用mysql扩展,将来会删除它:使用mysqli或PDO代替
这是受影响的代码:
class wdClient {
var $dbLink; // The database link
var $prefix; // Table prefix
var $script; // The script running
/**
* Construct a new directory object.
*/
function wdClient() {
error_reporting(E_ALL ^ E_NOTICE);
$this->prefix = WDDBPREFIX;
// Connect to the database
$this->dbLink = mysql_connect(WDDBHOST, WDDBUSER, WDDBPASSWD);
// Select the database
mysql_select_db(WDDBNAME, $this->dbLink) or die('Sorry, The site is currently unavailable!');
}
其中WDDBPREFIX
,WDDBHOST
,WDDBUSER
,WDDBPASSWD
,WDDBNAME
已在配置文件中定义。
我尝试过简单地使用mysqli_connect
代替mysql_connect
,但它无效。
答案 0 :(得分:0)
嗯,正如这里http://php.net/manual/en/function.mysqli-connect.php指出的那样,你应该做这样的事情:
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
显然,在你的情况下,它将如下所示:
$link = mysqli_connect(WDDBHOST, WDDBUSER, WDDBPASSWD, WDDBNAME);
然后你可以继续你的代码......
if (!link){
die('Sorry, The site is currently unavailable!');
} else{
// write your SQL here and fetch it
}
答案 1 :(得分:0)
注意:永远不要使用MySQL,请使用此方法!
//MySQLi information
$db_host = "localhost";
$db_username = "username";
$db_password = "password";
//connect to mysqli database (Host/Username/Password)
$connection = mysqli_connect($db_host, $db_username, $db_password) or die("Error " . mysqli_error());
//select MySQLi dabatase table
$db = mysqli_select_db($connection, "table") or die("Error " . mysqli_error());
祝你好运!