Php mysqli_num_行上载到Web服务器时出错
我有以下代码:Php mysqli_num_行上载到Web服务器时出错,php,mysql,Php,Mysql,我有以下代码: $query = "SELECT * FROM delegations where EMail='". $_REQUEST["user"] ."' AND Password = '". Encrypt($_REQUEST["pass"]) ."' "; $results = mysqli_query($con, $query); if(mysqli_num_rows($results) > 0) { while($row = mysqli_fetch_array
$query = "SELECT * FROM delegations where EMail='". $_REQUEST["user"] ."' AND Password = '". Encrypt($_REQUEST["pass"]) ."' ";
$results = mysqli_query($con, $query);
if(mysqli_num_rows($results) > 0) {
while($row = mysqli_fetch_array($results)) {
$_SESSION["login"] = $row["ID"];
echo "Welcome <b>" . $row["FirstName"] . "</b>! You have logged in succesfully! <a href=\"index.php\">Click here</a> to continue!";
}
有什么建议吗?您的
mysqli\u查询失败,请添加错误处理程序以显示错误
$results = mysqli_query($con, $query) or die(mysqli_error($con));
我认为$results应该是错误的;使用mysqli\u error
可以跟踪此错误
否则检查
var_dump($results);
使用mysqli
本身并不会阻止sql注入。开始使用准备好的语句。另外,我对函数Encrypt
寄予厚望,该函数旨在对密码进行哈希运算,而不是对密码进行加密。现在和将来的建议-如果您有一个布尔函数,请检查返回的结果。您没有检查查询是否成功。我真的不知道为什么人们不检查函数的返回值,这可能会减少50%的关于SO的问题,并节省我的否决票(如果你想知道为什么你在这里得到否决票,这是因为你没有谷歌,也没有阅读php文档)。好吧,结果是MySQL用户的权限设置不正确。谢谢
$results = mysqli_query($con, $query) or die(mysqli_error( $con ));
var_dump($results);