2010-07-29 127 views
-1

我的代碼 -警告:mysql_real_escape_string()?

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

但將警告 -
警告:mysql_real_escape_string()[function.mysql實時逃逸字符串]:拒絕訪問用戶 'ODBC' @ 'localhost' 的(使用密碼:否)在C:\ XAMPP \ htdocs中\圖片\ confirm_login_credentials.php上線3


警告:mysql_real_escape_string()[function.mysql實時的逃逸字符串]:鏈接到服務器無法在C:\ xampp \ htdocs \ pics \ confirm中建立_login_credentials.php上線3

回答

5

mysql_real_escape_string需要建立的鏈路數據庫以區分實際使用的字符編碼:

注:一個MySQL連接使用mysql_real_escape_string(之前需要)否則將生成級別爲的錯誤E_WARNING已生成,並返回FALSE。如果沒有定義link_identifier,則使用最後一個MySQL連接。

看起來你沒有那個時候打mysql_real_escape_string

+0

query($ q)或die(mysqli_error()); (mysqli_num_rows($ result)== 1) 如果(mysqli_num_rows($ result)== 1){ \t setcookie('authorized',1,0); \t header(「Location:index.php」); } else { \t header(「Location:login.php」); \t } ?> – nectar 2010-07-29 09:46:37

+0

@amanda:MySQL和MySQLi是兩個不同的東西。改爲使用'mysqli_real_escape_string'或'$ mysqli-> real_escape_string'。 – Gumbo 2010-07-29 10:27:42