top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

    Get Free Article Updates

Facebook Login
Site Registration

Advantages of PHP In MySQL Environment

+1 vote

Advantages of PHP In MySQL Environment

A scripting tool enables you to control one or more applications when executed. PHP is a scripting tool designed for Web development. PHP supports embedding scripts into HTML code. Developers can use PHP scripts to create HTML Web pages that can read and write data from a database.

PHP is a scripting language that is executed at run-time. It enables interaction of the application with the database. You can use PHP and MySQL together to manage data on the web. PHP is compatible with MySQL. You can also store and manage, information from the database. The below figure shows the interaction between the client, server, and database.


Here the server is connected to several clients. The database, server, and client maintain a two-way communication. This system appears to be simple; however, it has certain limitations. For example, when a client requests for data, the browser sends a request to the server. The server locates the data from the database, and returns it to the browser. If several clients make a request to the server for the same data, then the server will return the data to all the clients. This results in slow performance of the system.

The advantage of using PHP is that the database can be accessed directly through a web page. In this scenario, the client will request for a PHP file. The PHP pre-processor will connect to the database, retrieve the data, convert the data into HTML format, and send it to the browser.

Following are some examples of real-world websites where databases are used:

  • Online Ticket Reservation: In an online reservation system you can reserve a seat using the Internet. Your action updates the backend or the database of this booking system. You can access several parts of the database by changing the Uniform Resource Locator(URL).
  • Message Boards: On the Internet, message boards are widely present that run on MySQL and PHP. It is an online discussion site where messages can be posted. Message boards running on PHP and MySQL are more efficient because you need to update only one page and the changes are automatically reflected in others.
  • Marketing Websites: Consider that a large Website is required to be updated. The Website can be update using few PHP scripts as the information related to these pages is stored in MySQL database. The PHP scripts accesses the MySQL database to obtain the information about the pages.
  • Advertising Banners: Consider a website where several advertisement banners are present on the site. These banners are stored in a database on the server. You can call a PHP script to display each banner. In order to insert, modify, or delete a banner you have to access the database. A PHP script can be written to select the database from which the banner will be displayed. The PHP script would select and display the correct banners for the pages on the site.

To run a PHP script, you will need to install the following software:

  • Web Server
  • PHP
  • MySQL

PHP supports different operating system such as Mac OS X, Linux, UNIX, and Windows

Both PHP and MySQL are open source. This feature makes them cost effective as compared to other software products.

MySQL also supports the command line interface. This interface enables the PHP page to access the database and display the query results.

You can use PHP scripts to control the administration activities of the database. However, it is better to install a PHPMyAdmin on the sever. PHPMyAdmin is an administrative interface for MySQL databases. It consists of set of free scripts for administration of the database.

posted Nov 10, 2017 by Jon Deck

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button

Related Articles

The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).

First Normal Form The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic).

Second Normal Form Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.

Third Normal Form I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not fully dependent on the primary key, but dependent on another value in the table.


We can always fetch from one database and rewrite to another. here
is a nice solution of it.

$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);$db2 = mysql_connect("host","user","pwd")
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);

At this point you can only fetch records from you previous ResultSet,
i.e $res1 – But you cannot execute new query in $db1, even if you
supply the link as because the link was overwritten by the new db.
so at this point the following script will fail

$res3 = mysql_query("query",$db1); 

//this will failSo how to solve that?
take a look below.

$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);
$db2 = mysql_connect("host","user","pwd", true)
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);

So mysql_connect has another optional boolean parameter which
indicates whether a link will be created or not. as we connect to the
$db2 with this optional parameter set to 'true', so both link will
remain live.
now the following query will execute successfully.

$res3 = mysql_query("query",$db1);
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.