1
我想在表中最後一行輸出激活值,但我收到此錯誤:得到最後一行的值表
Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\wamp64\www\mci_form\show.php on line 11
代碼:
$hostName = 'localhost';
$userName = 'root';
$password = '';
$DBName = 'hamrahaval';
$connection = new mysqli($hostName,$userName,$password,$DBName);
$query = "SELECT activation_code FROM subscribers ORDER BY id DESC LIMIT 1";
$result = $connection->query($query);
echo $result;
'print_r($ result)';回聲的東西,它需要是一個字符串,或可轉換爲字符串 – hlfrmn
閱讀此http://php.net/manual/en/mysqli-result.fetch-assoc.php –
'$連接 - >查詢'返回一個'mysqli_result'結果,你不能用'echo'打印它的數據。爲此,你必須使用'print_r($ result)' –