Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有人能帮我弄明白这个php错误消息的含义吗?_Php_Mysql_Forms - Fatal编程技术网

有人能帮我弄明白这个php错误消息的含义吗?

有人能帮我弄明白这个php错误消息的含义吗?,php,mysql,forms,Php,Mysql,Forms,可能重复: 这是我的密码 $con = mysql_connect("localhost", "root", ''); if (!$con) { die('Cannot make a connection'); } mysql_select_db('yumbox_table', $con) or die('Cannot make a connection'); isset($_POST['user_name'], $_POST['password'], $_POST['u

可能重复:

这是我的密码

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

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


mysql_select_db('yumbox_table', $con) or die('Cannot make a connection');    
isset($_POST['user_name'], $_POST['password'], $_POST['user_type']);

$data = mysql_query("SELECT * 
                       FROM users 
                      WHERE user_name == ($_POST['user_name']) 
                        AND ($_POST['password']) 
                        AND ($_POST['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);

每当运行此代码时,我都会收到以下消息:

您需要发布错误以了解更多详细信息。但有几件事我注意到了

if(isset($_POST['user_name'], $_POST['password'], $_POST['user_type'])){
    $data = mysql_query("SELECT * from users 
             where user_name = '".mysql_real_escape_string($_POST['user_name'])."' and 
                   password  = '".mysql_real_escape_string($_POST['password'])."' and 
                   user_type = '".mysql_real_escape_string($_POST['user_type'])."' ");

    if(mysql_numrows($data) == 1) {
       $info = mysql_fetch_array($data);
       echo("Success!!");
    } else {
       echo("BIG FRIGGIN FAILURE!!");
    }
}
else{
   echo "Required Data Missing";
}

mysql_close($con);
mysql_query("SELECT * from users where user_name == ($_POST['user_name']) and ($_POST['password']) and ($_POST['user_type'])")
您需要将此更改为

//do escaping here. See note below.
$username = isset($_POST['user_name']) ? mysql_real_escape($_POST['user_name']) : '';
$pass     = isset($_POST['password']) ? mysql_real_escape($_POST['password']) : '';
$type     = isset($_POST['user_type']) ? mysql_real_escape($_POST['user_type']) : '';

mysql_query("SELECT * from users where user_name = '{$username}' AND password = '{$pass}' AND user_type = '{$type}'")
你需要逃避价值观

MySQL比较是
=
而不是
=
(感谢您指出@jeremysawesome)

您需要对照POST值检查该列

你也有一个。请至少使用。更好的办法是,换成


您需要将您的
isset
check分配给一个变量并进行检查。否则这只是一种浪费。

在将POST值插入查询之前,需要先对其进行转义。在数据库查询中使用POST值之前,应该先对其进行转义

与此相反:

$data = mysql_query("SELECT * from users where user_name == ($_POST['user_name']) and ($_POST['password']) and ($_POST['user_type'])"
这样做:

$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' AND user_type == '$user_type'");

请注意,我假设表中的列是“用户名”、“密码”和“用户类型”。

什么错误消息,在这里发布,可能他是指他得到一个空白页。他是否打开了错误显示?请阅读有关SQL注入的内容我不完全确定查询在做什么
。。。其中username=$\u POST['username']和$\u POST['password']以及$\u POST['usertype']
。那没有多大意义。而且,是的,你的代码是一个巨大的洞,等待着黑客。@prodigitalson:它开始了。OP希望我们为他们做这一切。确保使用
mysql\u real\u escape\u string
清除插入的值。另外-我相信双
=
应该是一个用于SQL比较的
=
。@jeremysawesome确实!更新answer@jeremysawesome当我开始正确地阅读问题时,我注意到了一些其他的东西