The link error can really only mean it can't login to your database as far as i know. You might need to turn on PHP errors so you can see the connection error. You can add ini_set('display_errors', 'on'); to the top of your PHP page then run it again. My guess is that will show an error saying the mysql_pconnect call has failed.
$dname is the connection to your MySQL database. With your original error, it means $dbname is null which means it failed to connect to MySQL for some reason.
-justin