Hope your db_connect.php
is something link:
try {
$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
And if you are using the connection object outside for your connection file, then you have to access that object into your particular file with the use of global
And as i know, you getting this error because you didn't called the object $db
in your file imageprocessor.php
, try with this:
function get_files($id) {
global $db;
$query = $db->prepare("SELECT * FROM files INNER JOIN file_profile_join ON files.id = file_profile_join.file_id WHERE file_profile_join.profile_id = " . $id . " GROUP BY files.id");
try {
$query->execute();
$rows = $query->fetch();
} catch (PDOException $e) {
die($e->getMessage());
}
}