Simple mysql connection from PHP:
Create file
config.php in file insert this lines and edit by your server configuration.:
Code:
<?php
$db_host="localhost"; // Mysql hostname ( by default it should be localhost)
$db_user="username"; // Mysql username
$db_pass="password"; // Mysql password
$db_name="database"; // Database
?>
Now create file to connect to your database.
Create file
database.php and insert this lines:
Code:
<?php
db_connect(); // I created funcion to connect to mysql because it much more easy to use.
function db_connect()
{
include('config.php'); // This line will include config.php to get configuration.
if(!mysql_connect($db_host,$db_user,$db_pass)) er_exit(mysql_error());
if(!mysql_select_db($db_name)) er_exit(mysql_error());
}
?>