警告:mysql_real_escape_string()?

时间:2010-07-29 08:58:16

标签: php

我的代码 -

$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);

但它会发出警告 -
警告:mysql_real_escape_string()[function.mysql-real-escape-string]:在C:\ xampp \ htdocs \ pics \ confirm_login_credentials.php中拒绝用户'ODBC'@'localhost'(使用密码:NO)的访问权限第3行


警告:mysql_real_escape_string()[function.mysql-real-escape-string]:无法在第3行的C:\ xampp \ htdocs \ pics \ confirm_login_credentials.php中建立到服务器的链接 < / p>

2 个答案:

答案 0 :(得分:5)

mysql_real_escape_string需要建立一个到数据库的链接,以区分实际使用的字符编码:

  

注意:在使用 mysql_real_escape_string()之前需要MySQL连接,否则会生成级别为 E_WARNING 的错误,并且为FALSE 返回。如果未定义 link_identifier ,则使用最后一个MySQL连接。

在调用mysql_real_escape_string时似乎没有。

答案 1 :(得分:1)

http://www.webmasterworld.com/php/3120893.htm

您需要先建立数据库链接。

mysql_real_escape_string() takes a connection handler and escapes the
     

根据当前的字符串   字符集。折旧,   mysql_escape_string [us3.php.net]   不需要连接

相关问题