PHP MySQL tutorial | How to use mysql and php for web development

Brief about MySQL

MySQL is an open source relational data base management system now owned by Oracle. MySQL is particularly popular for web based applications. It is being supported by most of server side scripting languages like PHP. Many big sites use MySQL as database like Wikipedia and youtube as well. MySQL is multi-user and multi-threaded DBMS.

LAMP platform, which is very popular platform, MySQL is one of 4 components.. where:

  • L = Linux
  • A = Apache
  • M = MySQL
  • P = PHP

MySQL is available and can be installed on important Operating systems like Linux, BSD unix, Windows and Mac.


While PHP can work with any database like Oracle, Microsoft SQL Server etc. the most widely used is PHP with MySQL.

PHP provides many built-in functions to work with MySQL database. This chapter details about important functions available to connect, and query through MySQL database for retrieving data, inserting data and deleting data. Detail of each function can be found on their respective chapters, linked within this guide.

Before starting to work with MySQL database we assume that you have downloaded and installed MySQL. The purpose of this chapter is to explain about working on MySQL database with PHP functions. And not working inside MySQL to perform admin or other operations. For that go through MySQL tutorial.

We also assumed you have created:

a database testdb

with user name = testuser

password = testpassword

Important Functions of PHP for MySQL

Establishing connection to MySQL database

Using mysql_connect to connect with MySQL database

Insert Data

Retrieving/Select data

Update Data