注意:尝试获取非对象错误的属性

时间:2017-03-12 10:30:31

标签: object undefined

您好我的脚本问题我最近将所有脚本升级到php 7并且我差不多完成但我无法解决此错误.....

注意:尝试在第201行的/mnt/web121/d2/33/58167933/htdocs/includes/functions.php中获取非对象的属性

有人可以帮我解决这个问题吗?

$drop =mysqli_query($con,"SELECT * FROM casinos");

while($tard=mysqli_fetch_object($drop)){
    $per = mysqli_fetch_object(mysqli_query($con,"SELECT * FROM users WHERE username='$tard->owner'"));
    if ($per->status == "Dead" or $per->status or "Banned"){
        mysqli_query($con,"UPDATE casinos SET owner='0' WHERE casino='$tard->casino' AND owner='$tard->owner'");
    }

}

这是第201行:

 if ($per->status == "Dead" or $per->status or "Banned"){

1 个答案:

答案 0 :(得分:0)

$drop = $con->query("SELECT owner FROM casinos");
while ($tard = $drop->fetch_row()) {
    $con->prepare("SELECT status,casino,owner FROM users WHERE username=?")
         ->bind_param("s", $tard[0])->execute()
         ->bind_result($status, $casino, $owner)->fetch()->close();
    if (in_array($status, ["Dead", "Banned"], true)) {
         $con->prepare("UPDATE casinos SET OWNER='0' WHERE casino=? and owner=?")
             ->bind_param("ss", $casino, $owner)->execute();
    }
}

请仔细检查您的SQL字段名称。