Warning: mysql_real_escape_string(): Access denied for user ''@'localhost' (using password: NO)

前端 未结 5 632
迷失自我
迷失自我 2021-01-18 21:18

When is use the following code without mysql_real_escape_string, works fine. I simply trying to grab a text string that may have apost. from an input form and format it to p

相关标签:
5条回答
  • 2021-01-18 22:09

    Try mysqli_real_escape_string instead.

    0 讨论(0)
  • 2021-01-18 22:12

    You must connect with database first before using Warning: mysql_real_escape_string()

    0 讨论(0)
  • 2021-01-18 22:14

    No, you shouldn't mix mysql and mysqli.

    Use here instead of mysql_real_escape_string($var):

    $con->real_escape_string($var);
    
    0 讨论(0)
  • 2021-01-18 22:19

    You're at risk of MySQL injections. Never insert data directly to a database without some sort of projection first. It's a major security risk. Also use mysqli_real_escape_string instead, and note that your $_POST[webSite] is unprotected.

    Also, your error means that your database details are not correct.

    0 讨论(0)
  • 2021-01-18 22:19

    A working code example that is a solution to this problem is available here:

    http://www.w3schools.com/php/func_mysqli_real_escape_string.asp

    0 讨论(0)
提交回复
热议问题