我目前遇到以下脚本的问题。执行脚本后,我确实收到消息“连接正常!” 但是,我也收到以下消息:
警告:mysql_query() 期望参数 2 是资源,在第 11 行的 /opt/lampp/htdocs/worldofclucky.net/scripts/auth.php 中给出的对象
警告:mysql_fetch_array() 期望参数 1 是资源,在第 12 行的 /opt/lampp/htdocs/worldofclucky.net/scripts/auth.php 中给出 null
知道我做错了什么吗?我远不是 PHP/MySQL 专家,我什至不认为自己是新手...我确实做了一些测试,并且 $username 变量从上一页正确发送,并且在输入SELECT * FROM forum.mybb_users WHERE username = 'x_clucky' LIMIT 1
MySQL 客户端时,它提供您期望获得的所有信息。PHP代码如下:
<?php
$username=$_POST["username"];
$hashed_password = md5($_POST['password']); /* For MyBB its $mybb->input['password'] */
$con=mysqli_connect("worldofclucky.net","clucky","CENSORED","forum");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else { echo "Connection was OK!\n";}
$query = mysql_query("SELECT * FROM mybb_users WHERE `username` = '$username' LIMIT 1",$con);
$row = mysql_fetch_array($query);
$encrypted_password = md5(md5($row['salt']).$hashed_password);
if($encrypted_password == $row['password']) {
echo "<script>alert('test');</script>";
}
mysqli_close($con);
?>
提前感谢您的帮助