That because you broke an if(){}else{} clause,
Line 17: else {
Line 18: / Now we will write a query to insert user details into database /
What I said was that you need to MOVE the CONNECTION and Associated elements like the LOGIN information, you don't need to move your query stuff.
EG.
$host = "fdb5.freehostingeu.com"; // Host name...change it to your configuration information.
$username = "1487284_mydb"; // Mysql username...change it to your configuration information.
$password = "l"; // Mysql password...change it to your configuration information.
$db_name = "1487284_mydb"; // Database name...change it to your configuration information.
// Connect to server
mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error());
//connect to database
mysql_select_db("$db_name") or die ('ERROR: Cannot connect'.mysql_error());
The rest only needed to say put.
The above elements should really be in an include file of their own and called with a require_once() include.
You might need to include a variable for your database handler, eg
$db = mysql_connect("$host", "$username", "$password") or die('ERROR: Cannot connect' .mysql_error());