我使用教程创建了一个管理页面。当我尝试登录我的数据库时,我收到错误消息,例如:
致命错误。未定义的函数
mysql_fetch_array
第22行。
当我尝试修复此问题时,我会看到空白页面。我知道我必须将所有内容升级到mysqli。我无法确定错误的位置。任何想法?
<?php
session_start();
if (isset($_SESSION["username"])) {
header("admin_index: admin.php");
exit();
}
?>
<?php
// Parse the log in form if the user has filled it out and pressed "Log In"
if (isset($_POST["username"]) && isset($_POST["password"])) {
$username = trim($_POST["username"]); // filter everything but numbers
and letters
$password = trim($_POST["password"]); // filter everything but numbers
and letters
// Connect to the MySQL database
include "../storescripts/connect_to_mysql.php";
$link = mysqli_connect("$db_host","$db_username","$db_pass","$db_name");
$result = mysqli_query($link,"SELECT username FROM admin WHERE
username='$username' AND password='$password' LIMIT 1"); // query the
person
// ------- MAKE SURE PERSON EXISTS IN DATABASE ---------
$existCount = mysqli_num_rows($result); // count the row nums
if ($existCount == 1) { // evaluate the count
while($row = mysql_fetch_array($result)){
$id = $row["id"];
}
$_SESSION["id"] = $id;
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
header("location: admin_index.php");
exit();
} else {
echo 'That information is incorrect, try again <a href="index.php">Click
Here</a>';
exit();
}
}
?>