Your website can have several PHP pages that all access your MySQL database. One time saving idea is to store your connection code in a separate file, and then include the file where needed.
More PHP / MySQL Quick Tips
For example, we can use the SQL code below to login to our MySQL database. Let's save this code in a file called datalogin.php.
<?phpNow, whenever we need to connect to our database, we just include this line in our PHP file:
// Connects to Our Database
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
mysql_select_db("Database_Name") or die(mysql_error());
?>
//MySQL Database ConnectYou can learn more about including files, and connecting to MySQL from PHP in the other tutorials on our website.
include 'datalogin.php';

