mysqli_result 类的对象无法转换为字符串错误 [英] Object of class mysqli_result could not be converted to string error
本文介绍了mysqli_result 类的对象无法转换为字符串错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我请求 Google 帮助我,但我没有走运.:-(这是生成错误的特定代码:
I asked Google to help me I got no luck. :-( Here's the particular code that generates the error:
$this->conn->query("UPDATE tz_members SET confirm='yes' WHERE usr='".$uname."'");
整个函数如下:
function update_confirm_field($code) {
$uname = $this->conn->query("SELECT usr FROM tz_members WHERE
confirm='".$code."'");
$this->conn->query("UPDATE tz_members SET confirm='yes' WHERE
usr='".$uname."'");
}
如果我错过了一些愚蠢的东西,请原谅我.谁能告诉我是什么导致了这个问题???
Forgive me if I have missed something stupid. Can anyone tell me what's causing the problem please???
推荐答案
问题在于 $uname 是一个对象,而不是一个字符串.您需要调用 $uname 的方法之一来访问数据.
The problem is that $uname is an object, not a string. You need to call one of $uname's methods to access the data.
function update_confirm_field($code) {
$uname = $this->conn->query("SELECT usr FROM tz_members WHERE
confirm='".$code."'");
while ($row = $uname->fetch_assoc()) {
$this->conn->query("UPDATE tz_members SET confirm='yes' WHERE
usr='".$row["usr"]."'");
}
}
应该这样做(或上述解决方案之一).
that should do it (or one of the above solutions).
这篇关于mysqli_result 类的对象无法转换为字符串错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文