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)' –