Hi everyone,
When I run the following code I recieve the following error:
"Fatal error: Call to a member function query() on a non-object in /home/mikepar8/public_html/update_record.php on line 65"
The file uploads into the correct directory, but the database is not getting updated.
The query works well other places in the page if I move it, but not here. Any help would be great. Thanks!
Here is my code: Line 65 is the $db->query($sql_update_1), which is about 9 lines down in this code.
$isbn = $_POST['isbn'];
$currentname = $_FILES['upfile']['name'];
$newname = $currentname.date("Ymdhis");
$uploaddir = "uploads/";
$imagename = $uploaddir.$newname;
if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploaddir.'/'.$newname)) {
print("file upload was successful");
$sql_update_1 = "UPDATE lounge SET image='$imagename' WHERE isbn = $isbn";
$db->query($sql_update_1);
} else {
print("file upload failed");
}