2012-06-27 29 views
0

我一直在收到此錯誤註冊引用新的返回值被棄用

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 80 

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\Config.php on line 166 

Fatal error: Class 'mysqli_connect' not found in C:\xampp\htdocs\bb2\includes\classes\connection.php on line 3 

我不知道爲什麼,這是我的代碼

這是config.php文件

<?php 
    define("DB_HOST","localhost"); 
    define("DB_USER","root"); 
    define("DB_NAME","beatbeast"); 
    define("DB_PASSWORD","123192"); 
?> 

這是我的連接.php

<?php 
    require_once('config.php'); 
    $mysqli = new mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
+0

看看相關的問題,以正確的,也有很多類似的問題。 –

+0

首先,你確定你有mysqli包括在PHP中,你的MySQL數據庫是4.1.3或更高? ---試試這個$ mysqli = new mysqli('localhost','my_user','my_password','my_db'); – swapnesh

+0

[Xampp 1.7.4 and PHP 5.3.5(Deprecated warnings)]的可能重複](http://stackoverflow.com/questions/5617605/xampp-1-7-4-and-php-5-3-5-不推薦使用 - 警告) – Amber

回答

3

您不應該使用newmysqli_connect - mysqli_調用的過程版本不使用對象語法。

如果要使用new,請使用new mysqli()

至於棄用警告,請參閱this question

+0

如果我用最新版本重新安裝xampp會有幫助嗎? – user962206

0

檢查mysqli啓用或不在php_ini文件中,並檢查文件「php_mysqli.dll」是否存在於C:\ xampp \ php \ ext目錄中。

+0

mysqli已啓用。還有php_mysqli.dll存在 – user962206

0

您可以通過禁用過時的消息:

error_reporting(E_ALL | E_DEPRECATED); 

或找到的代碼(功能)的問題的行,把一個@在它的前面。

0

如果mysqli的啓用那就試試這個代碼塊 -

<?php 
require_once('config.php'); 
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
if (mysqli_connect_error()) { 
    die('Connect Error (' . mysqli_connect_errno() . ') ' 
      . mysqli_connect_error()); 
} 

echo 'Success... ' . $mysqli->host_info . "\n"; 

$mysqli->close(); 
相關問題