2

问题已解决。UserControl 函数关闭数据库连接。谢谢

当我厌倦了real_escape_string()功能时,出现了问题

致命错误:在...中的非对象上调用成员函数 real_escape_string()

Sql类:

class Sql {

    protected $mysqli = '';
    private $table = '';
    private $where = '';
    private $limit = '';
    private $orderby = '';
    private $data = '';
    private $columns = '';

    function __construct(){
        try{
            if(!$this->mysqli){
                $this->mysqli = new mysqli(VTConnectIP, VTConnectRoot, VTConnectPass, VTConnectDB)
                                                                        or die(mysqli_connect_error());
                $this->tr_fix_db();
            }
            return;
        }catch(Exception $ex){
            echo $ex->getMessage(); 
        }   
    }

扩展类:

class LoginClass extends Sql
{
    private $username;
    private $password;
    private $email;
    private $errors = array();

    public function __construct(){
        parent::__construct();
    }

    public function username($data){
        $this->UserControl($data);
        $this->username = $this->mysqli->real_escape_string($data); // Error Code
        return $this;
    }
4

0 回答 0