【发布时间】:2019-07-25 00:23:23
【问题描述】:
我正在尝试执行此查询以测试注入。 我的查询中的错误在哪里?
<?php
$query= "SELECT * FROM login where email = '1' or '1' = '1' limit 1;/*' and password = '1e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855223'";
$result = mysqli_query($connection,$query) or die(mysqli_error($connection));
?>
结果错误: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 = '1e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b785' at line 1
如果我在 mysql 工作台中进行查询,它可以正常工作,但是当放在 mysqli 中时,它会给出错误。
感谢您的帮助和倒数。 简单的答案是使用 # 而不是 /*。
再见
【问题讨论】:
-
您最好使用参数化查询和准备好的语句。这样你就不需要测试各种 SQL 注入了。
-
我知道。但是为什么代码不起作用?
-
PHP 无效,请尝试
--而不是/*。 -
如果将字符串放在 mysql 工作台中,它可以正常工作。但是如果我通过 php mysqli 使用它就不会。这是为什么?看看我的编辑。
标签: php mysqli sql-injection