In my application I have a generic query that applies to multiple users. There are instances where the table structure may differ between users. I have a query that I only want to apply to the users where the column exists in their table.

```
function get_item($user_id) {

    global $dbh;

    $sth = $dbh->query ("SELECT item_type FROM items WHERE user_id = '$user_id'");

    $row = $sth->fetch();

    $item_type = $row['item_type'];

    return $item_type;

}

```

If the column 'item\_type' does not exist in my table, I want to ignore it, and set the $item\_type variable to NULL. 

For these users, I am getting the error on the query line of code:

> 
> Fatal error: Uncaught exception 'PDOException' with message
>  'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'item\_type' in
>  'field list' in /item\_display.php:5
> 
> 
> 

Any ideas?