You should have your connection string before any sql operation. So, it would be like,
$connection=mysql_connect($host,$user,$pass);
if(!$conn) {
echo "Error connecting.";
} else {
echo "Connected.";
}
Instead of using if and else, you can use die function with mysql_error function to know the error in your mysql statement. die ends the execution of the script. (Its an alias of exit). $connection = mysql_connect($host,$user,$pass) or die(mysql_error());
:) Cheers,
Naveen