Tuesday, May 15, 2018

Connect To MySQL Database in PHP

Here is a simple code to connect MySQL to PHP.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

connect.php

<?php
define(MYSQL_HOST, 'localhost');
define(MYSQL_USER, 'root');
define(MYSQL_PASS, '');
define(MYSQL_DB, 'USERSDB');

$db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
if (!$db)
{
die('<br />Failed to connect to host "' . MYSQL_HOST . '".');
}
else
{
mysql_select_db(MYSQL_DB);
}
?>

No comments:

Post a Comment