$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
After speaking to the hosting provider it seems the error was the way that the php duplicated reference to the database.
ie.
mysql_select_db($database_DBNAME, $DBNAME);
mysql_query($query_limit_RSNAME, $DBNAME)
to get this to work I had to change the syntax to:
mysql_select_db(DBNAME);
and take out the reference to the DBNAME as follows:
mysql_query($query_limit_RSNAME).
Would this be anything to do with conflicting versions of php?.