Wednesday 15 August 2012

Day 3/10 Php / MySQL - Learn PHP in 10 days

MySQL is an open source project just like PHP so that's why it has gained so popularity in such a short span of time.

There are Few stages when creating a php application which is going to interact with MySQL.

  • You will need to know the mysql server username and password.
  • You will need to know the mysql server URL / IP address
  • You will need to know the database you will be handling/updating.

  1. Tell the PHP script about your mysql server and database
  2. Send a sql command to insert/update/delete data
  3. Send a sql command to retrieve data 
  4. Manipulate the data according to user requirements

Important functions required to interact with a mysql server

  • mysql_connect() - to create an active link to mysql server
  • mysql_select_db() to select the database on a mysql server
  • mysql_query() - to send a sql command to mysql server.
  • mysql_close() - to close mysql server connection.
You will be surprised to know that php has no more functions for DB handling that's all you have to remmeber.

Let's connect to our DB in Vertrigo.  After running vertrigo application go to


  • Run vertrigo application
  • go to http://localhost/phpmyadmin/
  • create new database
  • create new tables in database. // it must not be so tought

PHP script to connect to mysql server in vertrigo !







PHP script to insert data into mysql table!








PHP script to Delete data from mysql table!





No comments:

Post a Comment