How to Connect Database With PHP

| Last Updated: | In: Mysql, PHP Tutorial


In this tutorial, I will explain simple and easy steps that will help you to create a database connection with MySql database with PHP applications. It is very easy to write a script in PHP to get connect with most of the popular open source database like MySql.

php-logo

 Example

Below is the complete example of how to make a connection with MySql using the PHP code. In the below example change the DB_SERVER, DB_USERNAME, DB_PASSWORD, and DB_DATABASE as per your database credential.

#connect with database

After defining the database variables, use the below code to make a connection with the database.

#Select the database

Now use the below code to select your database to use in your PHP based application.

Tags: , , , ,


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby.


You may also like:

Get Free Access of 450+ Scripts

Don't worry you'll not be spammed!

Featured eBook

WordPress Security Guide

Free Guide: Learn how to implement security guideline in your WordPress site...

DOWNLOAD

Free WordPress Setup Service

Free WordPress Setup

Want to Setup WordPress Blog Setup? I will help you in the setup of your WordPress blog.

Click Here

Discount Coupons

Pincode Finder

pincode-finder tool

Online Pincode Finder

Best tool to locate post Office address and pincodes of all india...

SEARCH NOW