mysqli_result类的对象无法转换为字符串 [英] Object of class mysqli_result could not be converted to string
本文介绍了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屋!
查看全文