I'm getting the error: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/content/57/8912457/html/brick-academy/add_file.php on line 34.
I can't figure out why it's giving that error, considering the code looks fine and it is inputing the correct data into the correct fields in the database.
The error is stopping the rest of my script from running.
Any help would be appreciated.
Code:
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");
}