当我加载包含以下代码的 PHP 页面时,我收到错误“调用非对象上的成员函数 fetch_object()”。它与以单词while开头的行有关。为什么会弹出这个错误?请忽略我的安全漏洞。
PHP 片段:
header('Content-Type:application/json;charset=utf-8');
$file_absolute = "---placeholder for correct file path---";
include_once($file_absolute);
$mysql = new mysqli($db_host, $db_username, $db_password, $db_name);
$verb_value = $_POST['verb_value'];
$mysql->query("SET CHARACTER SET 'utf8'");
$result = $mysql->query("SELECT present_tense FROM $verb_value");
$queryResult = array();
while ($row = $result->fetch_object())
{
$queryResult[] = $row->present_tense;
}