功能问题[不工作]

时间:2016-06-23 19:23:01

标签: php mysql function

所以我尝试了这段代码

 public function Check() {
        $this->val->GetData();
        $user = $this->core->FixName($this->val->user);

    $check = $this->db->query("SELECT `StaffBanned` FROM `accounts` WHERE `Username` = ".$this->db->escape($user)."");
    if($this->db->rows($check)) {
        list($staffbanned) = $this->db->fetch($check);
        $this->db->free($check);
        if($staffbanned = 1) {
        $this->Success("Success", "".$this->val->user." is currently serving a staff ban");
           }
        if ($staffbanned = 0) {
            $this->Alert("Success", "".$this->val->user." is currently not serving a staff ban");      
        }
    $this->db->free($check);
}
 $this->val->UnsetData();

}

所以它会检查这个人是否被禁止,由于某种原因它不起作用,你可以帮助我吗?

2 个答案:

答案 0 :(得分:2)

你在这里分配而不是测试:

if($staffbanned = 1) {

再来一次:

if ($staffbanned = 0) {

您可以使用==测试值,或使用===

测试真正的相等性

答案 1 :(得分:0)

由于Username是一个字符串,因此您需要在值周围加上引号。

$check = $this->db->query("SELECT `StaffBanned` FROM `accounts` WHERE `Username` = '".$this->db->escape($user)."'");