PHP-MySQL Connection

Hello i'm come back again, but now with PHP - MySQL Basic Tutorial.

Here we discuss about PHP MySQL Connection. The PHP Programmer usually know about this. There was mysql_connect and mysqli_connect. The function
mysql_connect and mysqli_connect actually have same objectives to provide a database connection, but mysqli_connect is newer version of mysql_connect.

So here is the code :

$hostname = "localhost";
$username = "root";
$password = "picas";
$database = "mydb";

$conn = mysql_connect($hostname, $username, $password)
or die("Connection fail ...");
mysql_select_db($database, $conn);

$link = mysqli_connect (localhost, root, picas, mydb);

mysqli_connect have shorter code than mysql_connect, and not using mysql_select_db.

Komentar FB

Probably Related Article


Related Posts by Categories

Widget by