Dismounted
59.***.***.***Connecting to a MySQL Database
Connecting to a MySQL Database Connecting to a MySQL database through PHP is very easy and also very important for all scripts that require MySQL. If you need your script to connect to a database, then you're going to need to combine variables and a simple code into your script. So lets get started, this is very easy and only requires you to add this code at the top of your script.PHP code:
<?php // Begin Variables $db_user = "USERNAME"; // Replace "username" with your username $db_pass = "PASSWORD"; // Replace "password" with your password $db_host = "HOSTNAME"; // Replace "hostname" with your hostname (usually localhost) $db_name = "DATABASE"; // Replace "database" with your database name $db_table = "TABLE"; // Replace "table" with the table you want to use // End Variables // Begin MySQL Connection mysql_connect($db_host, $db_user, $db_pass); @mysql_select_db($db_name) or die ("Unable to select database!"); // End MySQL Connection ?>
After you replace all of that, add it you your script. Make sure at the end of your script add this code to close the connection.PHP code:
<?php mysql_close(); ?>