title: Get closer to the pdo error
body: <p>I have an error 'Fatal error: Call to a member function upload_image() on a non-object in /data/home/.../.../.../.../upload_image.php on line 28'.
   The function upload_image()is in the image.func.php file and I can't find the error.
  In the upload_image() function is also a thumbnail function ans a image handler function so I think there are quite a lot of possibilities where the error can be. I am trying to get more details from the error handling but I am not getting any more then this fatal error.</p>
  
  <p>The upload_image function looks like this;</p>
  
  <pre><code>    class Images{ 
  private $db;
  
  public function __construct($database) {
  $this-&gt;db = $database;
  }
  
  public function upload_image($image_temp, $image_ext, $album_id) {
  global $thumbs;
  $image_name = $_FILES['image'] ['name'];
  $time       = time();
  
  $query = $this-&gt;db-&gt;prepare("INSERT INTO `images` VALUES (?, ?, ?, ?, ?, ?)");
  
  $query-&gt;bindValue(1, $image_id);
  $query-&gt;bindValue(2, $image_name);
  $query-&gt;bindValue(3, $_SESSION['id']);
  $query-&gt;bindValue(4, $album_id);
  $query-&gt;bindValue(5, $time);
  $query-&gt;bindValue(6, $image_ext);
  
  try{
  
  $query-&gt;execute();
  
  $image_id = $this-&gt;db-&gt;lastInsertId();
  $image_file = $image_id.'.'.$image_ext;
  
  move_uploaded_file($image_temp, 'uploads/'.$album_id.'/'.$image_file);      
  
  $thumbs-&gt;create_thumb('uploads/'.$album_id.'/', $image_file, 'uploads/thumbs/'.$album_id.'/');
  
  $source_image = 'uploads/'.$album_id.'/'.$image_file;;
  $destination = 'uploads/'.$album_id.'/'.$image_file;
  $tn_w = 900;
  $tn_h = 600;
  $quality = 100;
  $wmsource = 'watermark.png';    
     $this-&gt;image_handler($source_image,$destination,$tn_w,$tn_h,$quality,$wmsource);                                                                                             
  }catch(PDOException $e){
  die($e-&gt;getMessage());
  }
  }
  }
  </code></pre>
  
  <p>Here I try to get closer to the error with the try and catch block.</p>
  
  <p>The init.php looks like this;</p>
  
  <pre><code>session_start();
  require 'connect/database.php';
  require 'classes/users.php';
  require 'classes/general.php';
  require 'classes/album.func.php';
  require 'classes/image.func.php';
  require 'classes/thumb.func.php';
  require 'classes/bcrypt.php';
  
  error_reporting(1);
  
  $users      = new Users($db);
  $general    = new General();
  $albums     = new Albums($db);
  $Images     = new Images($db);
  $bcrypt     = new Bcrypt(12);
  $thumbs     = new Create_thumb();
  
  $errors = array();
  
  if ($general-&gt;logged_in() === true)  {
  $user_id    = $_SESSION['id'];
  $user       = $users-&gt;userdata($user_id);
  }
  </code></pre>
  
  <p>With the error reporting standing on 1.</p>
  
  <p>Are there more possibilities to get get closer to the error?
  Thanks... </p>