Database Connection Script using PHP and MySQL

<?php

$host = "localhost"; // customize to your host
$user = "root"; // customize to your user name
$password = ""; // fill blank if the user don't have a password
$db = ""; // fill with your database's name

$connect = mysql_connect($host,$user,$password);
if (!$connect) {
    echo "Connecting database failed.";
    echo mysql_error();
}

$selectdb = mysql_select_db($db);
if (!$selectdb) {
    echo "selected database failed";
    echo mysql_error();
}
?>

0 comments: