get_var result empty for query of custom table in plugin admin

There’s error in your query statement. Change to this

$post_id = $wpdb->get_var( "SELECT post_id FROM $customtable WHERE uniquecode="$uniquecode" AND blog_id = '$user_blog_id'" );