mysqli_result类的对象无法在第52行转换为字符串

时间:2017-03-21 17:18:41

标签: php mysql web

我的错误是

  

"Object of class mysqli_result could not be converted to string"

我的代码错误行是:

$type = queryMysql("SELECT `type` FROM `register` WHERE `name` = '$name'");
echo "$type";
if ($type == "admin")
        {
            die("Welcome back Admin $name <br> you can go to the control panel by clicking <a href='#'>here</a>");
        }
        elseif ($type == "user")
            echo "Welcome back user $name.";

“type”在数据库中定义为“admin”或“user”,错误行为“echo '$type';"

1 个答案:

答案 0 :(得分:0)

您的函数queryMysql不返回字符串,但会返回myslqi_result。你应该这样对待它,而不是作为一个字符串