mysql_num_rows giving error “mysql_num_rows() expects parameter 1 to be resource”

前端 未结 3 962
你的背包
你的背包 2021-01-25 07:39
public function doesUserExist($u) {

    $this->dbConnect();

    mysql_select_db($this->database);

    $sUser = mysql_real_escape_string($u);

    $query = \"SEL         


        
3条回答
  •  囚心锁ツ
    2021-01-25 08:18

    Actually you didn't executed query.

    public function doesUserExist($u) {
    
        $this->dbConnect();
    
        mysql_select_db($this->database);
    
        $sUser = mysql_real_escape_string($u);
    
        $query = "SELECT username FROM $this->table WHERE username='$sUser'";
        $query = mysql_query($query);
        $doesFieldExist = false;
    
        if (mysql_num_rows($query) > 0) {
            $doesFieldExist = true;
        }
    
        $this->dbDisconnect();
    
        return $doesFieldExist;
    
    }
    

提交回复
热议问题