Connect MySQL in PHP


PHPmyADMIN is a great web-based application to create, merge, export and import databases. Following script shows how to connect your MySQL database from PHP script.

===============================

MySQL Account Login Details
===============================

Host : localhost
Database name : myDB
Username : root
Password : pass12345

===============================

<?php

/* Declare some relevant variables */

$hostname = “localhost”; /* This is the hostname on which your MySQL is running */

$dbName = “myDB”;   /* Connecting remote server: $dbhost = ‘db.php-mysql-tutorial.com:3306’; */

$username = “root”;

$password = “pass12345”;

/* Establish a connection to database */

MYSQL_CONNECT($hostname, $username, $password) OR DIE(“Unable to connect to database”);

/* Select the database to work on */

mysql_select_db( “$dbName”) or die( “Unable to select database”);

?>

Advertisements

About Robiul

Robiul has 15 years of continuous successful career experience in ICT with extensive background in System Engineering, IT infrastructure design, operations and service delivery, managing IT projects / MIS functions for local and multi-national companies with in-depth knowledge of multiple operating systems as well as construct / manage small to medium size Data Center. Proven ability to design and implement medium to semi-large scale LAN/WAN/WLAN and system infrastructures. Academic qualification: Master of Science in Information Systems. Professional certifications are: MCSE, CCNA, ITIL and FoundStone Security Professional, VCP, NetAPP, CISSP etc.
This entry was posted in Others and tagged . Bookmark the permalink.