This is not the way SQL works. You have to state clearly what table in what database you like to work on.
You can set up the most liked db by
USE mydatabase;
and every request to a table will be passed to that database.
SELECT * FROM mytable;
SELECT * FROM mydatabase.mytable; -- same as above because of USE mytable;
The only way is to use Prepare and Execute (have a look at the docs), but with plain commands (SELECT, UPDATE,...) you can't reach your desired goal that way
UPDATE
You have to split the Query:
First Query
USE mycommondb;
SELECT `db` FROM site WHERE `url`='$site';
Second:
USE $db_from_site;
SELECT * FROM table;
(because of the $ i think it will be called from php ;o) )