PHP Connect to MySQL

PHP Connect to MySQL - Now, we will explain about connection PHP to MySQL. Before you do anithing with PHP Programming and MySQL database, you must create a connection.

If the connection are established, you can create databases, tables, or insert data and anything with MySQL database. The PHP syntax which use to create connection is mysql_connect( host, user, pass ) . Below the example script for create connection to MySQL databases.

<?php
$host = "localhost"; // if your host is localhost
$user = "root"; // if your user in MySQL is root
$pass = ""; // if your MySQL without password

// create connection
mysql_connect($host, $user, $pass) or die (mysql_error());
echo "Connection established"

?>
Save and access that script. If the display is "Connection established" without error, so your connection is successfull.

Paper 4Share - PHP Connect to MySQL

0 Response to "PHP Connect to MySQL"

Post a Comment