PHP mysqli_real_escape_string returning empty string

前端 未结 3 1755
陌清茗
陌清茗 2020-12-22 02:17

The code works fine if I don\'t use the mysql_real_escape_string function. But the function is returning nothing! I read that the problem may be due to the fact that I do no

相关标签:
3条回答
  • 2020-12-22 02:43

    According to http://php.net/manual/en/mysqli.real-escape-string.php you need to pass two parameters unless you are using the object oriented style.You should be using the format:

    mysqli_real_escape_string ( $link , $escapestr )

    Where $link is: A link identifier returned by mysqli_connect() or mysqli_init()

    And $escapestr is: The string to be escaped. Characters encoded are NUL (ASCII 0), \n, \r, \, ', ", and Control-Z.

    0 讨论(0)
  • 2020-12-22 02:49

    php.net says
    Procedural style
    mysqli_real_escape_string ( mysqli $link , string $escapestr )
    So you will need to add your $con to it:
    $title = mysqli_real_escape_string($con, $_POST["title"]);

    0 讨论(0)
  • 2020-12-22 02:54

    You need to pass the connection to the function

    $title = mysqli_real_escape_string($con, $_POST["title"]);
    
    0 讨论(0)
提交回复
热议问题