Undefined variable: row?

First, it’s not $wpdb->wp_posts, it’s just $wpdb->posts.

Second, you’re using prepare() incorrectly. You use prepare when you have some variable data that you need to safely insert into the query string, not otherwise. Using prepare on a known string does nothing and throws a warning.

For example:

$data="example string"
$query = $wpdb->prepare("SELECT post_title FROM {$wpdb->posts} where post_title = %s", $data);

And then $query will be the SQL string that you’re able to safely send to $wpdb->query. The string gets escaped, quoted, and inserted where that %s is.

If you don’t have any variable data that needs to be prepare’d for inserting into the query, then there’s no point in calling prepare.

For your case, since you’re not putting any variables into the SQL, just skip the prepare.

$test = $wpdb->get_var( "SELECT post_title FROM {$wpdb->posts}" );