我試圖創建在PHP中使用的mysqli MySQL數據庫的連接。當我一個獨立的頁面上執行以下代碼:新的mysqli對象爲空
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$link = new mysqli('localhost', 'myuser', 'mypass', 'dbname');
var_dump($link);
我得到的輸出是一個空的mysqli對象,其中的所有屬性都爲空。沒有錯誤或任何顯示。
我還沒有看到在Apache或MySQL日誌的所有條目。我對這個人很迷茫。
試'$鏈接=新的mysqli( '本地主機', '爲myuser', '爲mypass', 'DBNAME')或死亡(mysqli_error());' – crush 2012-02-15 22:18:13
@crush :我想你的意思是'$ link = new mysqli('localhost','myuser','mypass','dbname')或die(mysqli_connect_error());'。 'mysqli_error()'函數需要一個鏈接標識符作爲其參數。 – 2012-02-15 22:24:37
@Justin,我改變了你的建議,它根本沒有改變。在實例化mysqli對象之後,假設沒有錯誤,mysql_connect_error函數返回null。儘管mysqli對象的屬性都是null。當我轉儲$ link時,得到: – 2012-02-15 22:37:45