我收到錯誤:mysqli_fetch_assoc()期望參數1是/ home/content/57/8912457中給出的mysqli_result,布爾值/html/brick-academy/add_file.php on line 34.獲取SQL查詢錯誤,但正在使用正確的信息更新數據庫
我不明白爲什麼它給出了這個錯誤,考慮到代碼看起來不錯,它將正確的數據輸入到數據庫中正確的字段中。
該錯誤正在阻止我的腳本運行的其餘部分。
任何幫助,將不勝感激。
代碼:
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");
}
$ GLOBALS [「___ mysqli_ston」]似乎不是初始化的mysqli鏈接 – Moylin
爲了您的好處添加了其餘的代碼。它在其中一個包括。 – Jacques
[mysql \ _fetch \ _array()的可能的重複期望參數1是資源,布爾給出在選擇](http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to -be-resource-boolean-given-in-select) –