When you need to use MySQL database from your PHP file. You must connect to your MySQL on your web server, select the database you want and then make the command for browse your records, update, add or delete them. There are the database management commands called SQL language (Structure Query Language).
• Connect MySQL Database
Do it first when you need to use database on your file.
Both connections above should be often to use by many files in one site and you must to change your username and password in all files when you upload to the real server on the net. The best way, put these codes in a file, save it and then use include(); or require(); command in PHP files you want.
Just save the example codes above to "connectdb.php" and when you need to use MySQL connection use include(); command.
• Close Connection
Close your connection at the end of file for free your web server's buffer.