Can someone help me find out the meaning behind these errors? [duplicate]
Possible Duplicate:
Can anyone help me figure out the meaning of this php error message?
Here is the code:
$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);
and these is the error messages generated from said code:
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 开发者_StackOverflow社区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
- Some of your variables are not set. They are empty. Therefore the
Undefined index
messages - Your query is wring also. The comparison operator for strings is
=
, not==
. It should beSELECT * from users where user_name = '$user_name' AND password = '$password' AND user_type == '$user_type'"
- You forgot the
=
before theuser_type
column.
Not sure by the error in this part.
$data = mysql_query("SELECT * from users where user_name == '$user_name' AND password == '$password' user_type == '$user_type'") or die(mysql_error());
try using this
$data = mysql_query("SELECT * from users where user_name == '".$user_name."' AND password == '".$password."' user_type == '".$user_type."'") or die(mysql_error());
精彩评论