我收到错误消息:mysqli_fetch_assoc() 期望参数 1 为 mysqli_result,布尔值在第 34 行的 /home/content/57/8912457/html/brick-academy/add_file.php 中给出。
考虑到代码看起来不错并且正在将正确的数据输入到数据库中的正确字段中,我无法弄清楚为什么会出现该错误。
该错误使我的脚本的其余部分停止运行。
任何帮助,将不胜感激。
代码:
include_once('resources/init.php');
include_once('user_check.php');
$name = $_POST['name'];
$teacher = $_POST['teacher'];
$query = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT name_first, name_last FROM teachers WHERE teacher_id='$teacher'");
$row = mysqli_fetch_assoc($query);
$name_first = $row['name_first'];
$name_last = $row['name_last'];
$folder_name = $name_last . "-" . $name_first . "-ID-" . $teacher . "/";
$dirname = "files/" . $folder_name;
if(!is_dir($dirname)){
mkdir($dirname);
}
$dirname = $dirname . $_FILES['file']['name'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $dirname)){
$query = mysqli_query($GLOBALS["___mysqli_ston"], "INSERT INTO documents SET id_teacher = '$teacher', name = '$name', document = '$dirname'");
$row = mysqli_fetch_assoc($query);
header("location:file_manager.php");
}