I am trying to insert a new game and an image into my database and I have the following code:
$insert_query = "INSERT INTO Games (name, release_date, description, developer, publisher)
VALUES ('$name', '$release_date', '$description', '$developer', '$publisher')";
$insert = mysqli_query($mysql,$insert_query);
if (!$insert)
{
echo("Error description: " . mysqli_error($mysql));
}
$row = mysqli_fetch_assoc($insert);
$id = $row['id'];
echo $id;
$newImageName = "games".$id.".".$imageExt2;
$imageDestination = 'GamePictures/'.$newImageName;
move_uploaded_file($imageTmpName, $imageDestination);
$update_query = "UPDATE Games SET image = '$newImageName' WHERE name = '$name'";
The row gets inserted in the database, but I still get the error and it doesn't print an error message. Because of this error I also get a move_uploaded_file: failed error.
Does anyone know how I can fix this?