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 :


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

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



<?php
$link = mysqli_connect (localhost, root, picas, mydb);
?>


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


Komentar FB


Probably Related Article



0 comments:

Related Posts by Categories



Widget by