简体   繁体   中英

mysql_real_escape_string($value) not working

im trying to prevent sql injection with

mysql_real_escape_string($value)

here is my code, but it seem that i get a null value ,

$this->name_safe = mysqli_real_escape_string($this->name,$this->link);

            $this->query = "INSERT INTO student (complete_name, date_birth, gender, email, student_status)
            VALUES ( '$this->name_safe', '$this->date', '$this->gender', '$this->email_1', 'current')";

? thx

You have your function arguments in the wrong order. DB link comes first, then the string to escape.

http://php.net/mysqli_real_escape_string

mysqli_real_escape_string($this->link, $this->name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM