I am creating wordpress theme. I recieve this error in the textarea: Looking to get qualities on the non-object.

function add_map_url($post){

        global $wpdb;
        $info = $wpdb->get_var("SELECT * FROM $wpdb->contacts WHERE ID= $post->ID  LIMIT 1");
        $val = !empty($info) ? htmlspecialchars($info->link) : '';
        echo '<textarea name="link" rows="6" cols="30">'.$val.'</textarea>';
    }

It appears the issue leading to the mistake is: $info->link. Should i be altering the code:

function add_map_url($post){

            global $wpdb;
            $info = $wpdb->get_var("SELECT * FROM $wpdb->contacts WHERE ID= $post->ID  LIMIT 1");
            //$val = !empty($info) ? htmlspecialchars($info->link) : '';
            echo '<textarea name="link" rows="6" cols="30">'.$info.'</textarea>';
        }   

It's working and provides contacts ID.

The table contacts appears like:

contacts
ID     link

I can not evaluate which I am doing wrong. Thank you for any advice!

The query most likely is not coming back any rows matching the factors given, quite simply the row does not appear in the table. You are able to run the query in the mysql command line and find out whether it returns anything. You might want to alter the empty() call to is_object():

$val = is_object($info) ? htmlspecialchars($info->link) : '';