无法将mysqli_result类的对象转换为字符串
我收到错误消息:
Object of class mysqli_result could not be converted to string
这是我的代码:
$username2 = htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8');$con = mysqli_connect('localhost','root','','test');
$result = mysqli_query($con, "SELECT classtype FROM learn_users
WHERE username='$username2';");
echo "my result <a href='data/$result.php'>My account</a>";
回答:
回答:
您需要将其循环,然后访问记录。您只是不能直接将其用作$result
变量。
回答:
while ($row = $result->fetch_assoc()) { echo $row['classtype']."<br>";
}
以上是 无法将mysqli_result类的对象转换为字符串 的全部内容, 来源链接: utcz.com/qa/407133.html