Sunday, January 5, 2014

PHP MySQL Database tutorial

PHP MySQL Database tutorial :

What is PHP?

PHP is most popular server side scripting language used for web development. To know more about php and how to start with PHP programming CLICK HERE
PHP works with many databases. You can connect to many databases and manipulate with them with PHP. But the MySQL is most widely and popular databases with PHP. So now we learn more about MySQL.

What is MySQL?

MySQL is the widely used open-source Relational Database Management System(RDBMS). MySQL is the database used on the web and it is runs on the server side. MySQL is good for both small and large application. MySQL is reliable and easy to use database. MySQL is supported by number of platforms and It supports standard SQL.

So from this we got to know about both PHP and MySQL. So now we move to the PHP with MySQL that is how to use PHP with MySQL.

You can simply install PHP and MySQL on your PC with the help of complete package of XAMPP. XAMPP is acronym of  xml apache mysql php and perl. To know about how to install XAMPP on your windows machine please CLICK HERE

PHP MySQL Tutorial Content:

1) MySQL Connect Syntax :

First you have to connect to your mysql through PHP so you need to use mysql_connect().

Basic syntax for mysql connect is as below

mysql_connect(host name, username, password);
// Here host name is the name of host or ip address of host where mysql is installed

Try out the below code for mysql_connect()

//the example of MySQL database connection 

$conn = mysql_connect("localhost","","");
// write your mysql username and password in the second and third parameter of mysql_connect respectively
if ($conn) {
 echo ("Connection is succeed")
} else {
 echo ("Connection is fail")

2) MySQL Create database :
MySQL create database syntax is as below


3) MySQL execute Query :
Mysql execute query syntax is as below

Sorder="insert into table (val11,val2)";
mysql_query($order) ;
//The above command execute the insert sql command

4) MySQL fetch record :
The syntax of fetch single row or record from table is as below

$result=mysql_query("select id,name from student where id =10");



  echo "No record exist";




   $row= mysql_fetch_row($result);


echo $row[0];   //10

echo $row[1];   // suresh


Post a Comment