PHP not connecting properly to MySQL

I’m a PHP newb, first of all. So, hi. My domain is registered with GoDaddy (bad choice, in case you were curious) but I cannot get the PHP to connect with a MySQL database. I have all the information right, but GoDaddy is weird. The host name isn’t localhost and the database name and user id all have to be the same. Also, the password has to have at least 1 capital letter and 1 number. Is that a problem?

I’m just trying to follow basic tutorials but nothing is working out.
And It is on purpose when I say that the beginning of the host name, the user id and the database name are all the same.


<?php

header("Content-type: text/xml");

$host = "dbname.db.8675309.hostedresource.com";
$user = "dbname";
$pass = "Password1";
$database = "dbname";

$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");

$query = "SELECT * FROM products";
$resultID = mysql_query($query, $linkID) or die("Data not found.");

$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<entries>
";

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
    $row = mysql_fetch_assoc($resultID);
    $xml_output .= "	<entry>
";
    $xml_output .= "		<date>" . $row['date'] . "</date>
";
        // Escaping illegal characters
        $row['text'] = str_replace("&", "&", $row['text']);
        $row['text'] = str_replace("<", "<", $row['text']);
        $row['text'] = str_replace(">", "&gt;", $row['text']);
        $row['text'] = str_replace("\"", "&quot;", $row['text']);
    $xml_output .= "		<text>" . $row['text'] . "</text>
";
    $xml_output .= "	</entry>
";
}

$xml_output .= "</entries>";

echo $xml_output;

?>