I set up a database and table in a godaddy mysql database, and I know I have my user, pass and db info correct, but I keep getting the error "Can't connect to database" with no further info. Godaddy said I def. use 'localhost' as the hostname. I know I should be using PDO for security, but for now I simply want to make a simply connection to and test it using the most simple sql statement. Is it possible something in my code is wrong below that is keeping me from connecting? Or does the below look fine assuming my login info is correct?
//Connect To Database
$hostname="localhost";
$username="***";
$password="***";
$dbname="***";
mysql_connect($hostname,$username, $password) or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
mysql_select_db($dbname);
# Check If Record Exists
$query = "SELECT * from schools where schools_state=WA ";
$result = mysql_query($query);
if($result){
while($row = mysql_fetch_array($result)){
$name = $row["$school_name"];
echo "School: ".$school_name."<br/>";
}
}
?>