Are you using MySQL functions or the MySQL improved extention, your first code snippet you connect using the MySQLi Connection function, and the rest of them have queries handled with mysql_query() ??
Also, I suggest you use Objects for your code such as the MySQLi object or change to PDO for the Database Abstraction layer
Project back up the link should work now.