I have selected the database but for some weird reason it still says that it is not selected.
Connection lines:
$location = \"localhost\"; $user = \"
You forgot to pass the variable $link as the link parameter.
mysql_select_db('database', $link) or die(mysql_error());
EDIT: Try passing the database in the FROM parameter like
SELECT * FROM `database`.`table`