2011-04-29 50 views
0

可能重複:
Can anyone help me figure out the meaning of this php error message?有人能幫我找出這些錯誤背後的含義嗎?

下面是代碼:

$con = mysql_connect("localhost", "root", ''); 

if (!$con) 
{ 
    die('Cannot make a connection'); 
} 


mysql_select_db('yumbox_table', $con) or die('Cannot make a connection'); 

$user_name = mysql_real_escape_string($_POST['user_name']); 
$password = mysql_real_escape_string($_POST['password']); 
$user_type = mysql_real_escape_string($_POST['user_type']); 



$data = mysql_query("SELECT * from users where user_name == '$user_name' AND password == '$password' user_type == '$user_type'") or die(mysql_error()); 

$info = mysql_fetch_array($data); 

$count = mysql_numrows($data); 

if ($count==1) 
{ 
    echo ("Success!!"); 
} 
else 
{ 
    echo ("BIG FRIGGIN FAILURE!!"); 
} 



mysql_close($con); 

和這些是從生成的錯誤信息,所述代碼:

Notice: Undefined index: user_name in C:\wamp\www\login.php on line 12 
Call Stack 
# Time Memory Function Location 
1 0.0013 371904 {main}() ..\login.php:0 

(!) Notice: Undefined index: password in C:\wamp\www\login.php on line 13 
Call Stack 
# Time Memory Function Location 
1 0.0013 371904 {main}() ..\login.php:0 

(!) Notice: Undefined index: user_type in C:\wamp\www\login.php on line 14 
Call Stack 
# Time Memory Function Location 
1 0.0013 371904 {main}() ..\login.php:0 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== '' AND password == '' user_type == ''' at line 1 
+0

@ user717363停止發送垃圾郵件的問題。請更新您的原始問題並留下相關反饋。 – JohnP 2011-04-29 05:09:46

回答

0
  • 您的一些變量未設置。他們是空的。因此,Undefined index消息
  • 您的查詢也擰。字符串的比較運算符是=,而不是==。它應該是SELECT * from users where user_name = '$user_name' AND password = '$password' AND user_type == '$user_type'"
  • 你忘記了=之前的user_type列。
0

不知道由這部分的錯誤。

$data = mysql_query("SELECT * from users where user_name == '$user_name' AND password == '$password' user_type == '$user_type'") or die(mysql_error()); 

嘗試使用此

$data = mysql_query("SELECT * from users where user_name == '".$user_name."' AND password == '".$password."' user_type == '".$user_type."'") or die(mysql_error()); 
+0

編輯你的問題,添加代碼格式 – JohnP 2011-04-29 05:31:14

相關問題