u cannot do it in one line, however, 5 simple commands will do:
$db = mysql_connect("server.test.com", "username", "password");
mysql_select_db("mydb", $db);
$res = mysql_query("select name from table where id=2", $db);
$data = mysql_fetch_assoc($res);
mysql_close($db);
now, $data["name"] contains the value u r lookin for, u just have to set the db server, pw, user and name. note this lines do not use any error handling, so this should be added when usin this on a production system. pls check the docu for further details.
hth