PHP and MySQL – Basic Introduction

Categories Articles, DevelopmentPosted on
PHP-MySQL

PHP Stands for Personal Home Page, its a Script Language and Interpreter that is freely available and use Primarily on Linux Web Servers. MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by Oracle Corporation.

PHP:

PHP was from the outset made as a straightforward scripting stage called “Personal Home Page”. These days PHP is an option of the Microsoft’s Active Server Pages (ASP) innovation.

PHP is an open source server-side language which is utilized for making dynamic site pages. It very well may be inserted into HTML. PHP is normally utilized related to a MySQL database on Linux/UNIX web servers. It is presumably the most famous scripting language.  PHP is a broadly utilized universally useful scripting language and translator that is uninhibitedly accessible. A full clarification of all the PHP capacities, complete client manual and heaps of instructional exercises can be found on the PHP’s legitimate page. A most significant aspect regarding utilizing PHP is to have a PHP specific host.

MySQL:

MySQL is a uninhibitedly accessible open source Relational Database Management System (RDBMS) that utilizations Structured Query Language (SQL). SQL is the most well-known language for including, getting to and overseeing content in a database. It is most noted for its speedy handling, demonstrated unwavering quality, straightforwardness and adaptability of utilization. MySQL is a fundamental piece of pretty much every open source PHP application. Genuine models for PHP and MySQL-based contents are WordPress, Joomla, Magento and Drupal. A most significant aspect regarding utilizing MySQL is to have a MySQL particular host.

The distinguishing feature of PHP is that the scripting code is executed on the server, which generates HTML that is sent back to the client. The client receives the result of executing the script without knowing the underlying code. Developers can configure the web server to process all the HTML files (containing the PHP script).

PHP course is easy to learn for any newcomer, but also offers advanced programming features.

Using PHP with a Database System:

PHP, as a scripting language, is popular among web developers because of its ability to interact with database systems including Oracle and MySQL.

This article discusses the use of PHP scripting language with the MySQL database. Any website can require a variety of data or information to display and to retrieve them from the database. This can include display of a simple list to the running of the website based on data stored in the database.

Listed below are some examples where PHP and MySQL can be used together:

  • Digital Ad banners, where the PHP script can be used to retrieve a digital banner from the database, which then selects a random banner from its table records and sends it back to the calling script. The PHP script can also maintain a count of banner views and clicks from the website.
  • Internet forums or digital boards, which use PHP and MySQL to store and retrieve user messages.
  • Website designing, where the design of an entire website can be changed using a couple of PHP scripts, instead of changing and uploading each web page. The PHP script can access the MySQL database to retrieve all information about the web page.

Setting up the MySQL Database:

PHP & MySQL

The procedure of setting up the MySQL database varies according to the host. Every database would require a user name and password, in order to access the database. Database administration can be done using PHP scripts or using a program like PHPMyAdmin.

The next step is to create the database tables for storing the website information. Creating a database table using PHPMyAdmin is also simple. Alternatively, one can create and configure the entire database using the following PHP script:

CREATE TABLE tablename {

Fields

}Where the Fields are coded as fieldname type(length) extra_info

Example: first varchar(15) NOT NULL

The following command is used in the PHP script to connect to the MySQL database:

mysql_connect(localhost,$username,$password);

where:

  • localhost is the server address on which the web site is running,
  • $username is the user name for the database access
  • $password is the password for the database access

Executing PHP commands:

After configuring and connecting to the MySQL database, you can start executing PHP commands on the server.

Following are the 2 methods of executing a PHP command:

  • Entering the command in PHP using the following syntax:

Mysql_query($query):

  • This form of command can be used to repeat the command simply by changing the variable.
  • Defining the command as a variable. The result of the operation will be assigned to the variable.

Data Input and Output:

Inserting data using PHP is identical to the procedure of data input using HTML pages. The advantage of using PHP is that the script does not need to be changed for each new piece of input data. Users can also input their own data on the web page.

Then again, you can utilize factors to enter data into the database. Model:

$first=$_POST[‘first’];
$last=$_POST[‘last’];
$phone=$_POST[‘phone’];
$mobile=$_POST[‘mobile’];
$fax=$_POST[‘fax’];
$email=$_POST[’email’];
$web=$_POST[‘web’];

$query = “Addition INTO contacts VALUES
“,’$first’,’$last’,’$phone’,’$mobile’,’$fax’,’$email’,’$web’)”;
mysql_query($query);

This content is spared in the insert.php document, which can be called from the HTML structure. Utilizing this technique, information entered in the website page structure is put away in the characterized factors, which are then passed to the PHP.

To show (or yield) the entered information utilizing PHP, you can utilize the accompanying MySQL direction with the outcome doled out to the variable.

$query=”SELECT * FROM contacts”;
$result=mysql_query($query);

PHP gives 2 accommodation strategies, GET and POST to get the information put together by the structure into your PHP content. GET strategy shows the factors and the information in the page address, while they are undetectable in the POST technique. For instance, a content can be made that will show diverse pages relying upon the clicked connection.

yourpage.php?user=charles (to show Charles’s page)
yourpage.php?user=nathan (to show Nathan’s page)

Development:

At the point when joined together, talented PHP and MySQL engineers can manufacture extremely ground-breaking and adaptable Web/Internet/Intranet Applications. PHP and MySQL are alluded to as improvement apparatuses.

PHP and MySQL are Open Source, implying that they are free advancement apparatuses, and there is a huge network of devoted volunteer software engineers who add to make upgrades and are consistently adding highlights to it. The improvement instruments and database servers that require authorizing expenses have restricted programming assets contrasted with open source advancement apparatuses, which have a gigantic and quickly developing devoted and educated network that stretches out the world over.

There has been contradiction about which apparatus is better. Normally, the designer who is progressively acquainted with one instrument over the other will remain behind the device that the individual in question has involvement in.

With our experience, we have discovered that, PHP and MySQL are the best improvement devices. At the point when grown effectively, applications can be worked with perfect and straightforward ease of use, complex usefulness, speed, power and adaptability.

Great Development Practices:

One thing to take note of: No issue how incredible the advancement apparatuses are that you are creating with, if the application isn’t grown effectively, the final product may not be advantageous.

PHP and MySQL is assembled so anybody with a base measure of programming learning can assemble a program based web application. This simple section to PHP advancement can likewise make issues when an unpracticed developer takes on a huge Web Application venture and doesn’t think about security suggestions, versatility and the SQL execution time when there are huge simultaneous associations, just to begin.

Instances of muddled coding and messy SQL questions:

  • Not utilizing coding rules
  • Blending HTML in with PHP capacities
  • Coding irregularities
  • Utilizing various styles of capacity calls
  • Cluttered rationale
  • History and People that are behind PHP

PHP scripting language is written in C and is fueled by the Zend Engine. PHP was initially created by Rasmus Lerdorf in 1995 and later was reworked by Zeev Suraski and Andi Gutmans in 1997. Zeev Suraski and Andi Gutmans established Zend Technology and made the motor behind PHP, the Zend Engine. Suraski and Gutmans have been effectively engaged with taking PHP to its zenith achievement today.

PHP Popularity:

PHP is one of the most well known scripting dialects utilized in building dynamic destinations. PHP has arrived at its bleeding edge prevalence in 2009 by being utilized on in excess of 27,000,000 spaces.

What is Zend Engine?

Zend Engine is the PHP compiler and runtime motor. Zend Engine is liable for assembling the PHP Script into the Zend Opcode (Virtual Machine), at that point executing the opcodes and creating the outcomes into the Web Server.

The Zend Optimizer is a help that runs the records encoded by the Zend Encoder. The standard Zend run-time compiler utilized by PHP is for sure extremely quick, producing code that is typically 2 to multiple times quicker. In any case, an application that utilization Zend Optimizer can execute contents another 40% to 100% quicker. After PHP 5.3 Zend Optimizer is incorporated into the standard PHP circulation and there are no extra establishments required for it to work.

Zend Guard Compatibility: The encoded records must be incorporated with a good form of Zend Guard. At the point when you don’t know about the Zend Guard form, consistently utilize the most recent rendition of Zend Optimizer.

A professional Web/Graphic Designer, working as Freelancer since 2000. Designing is my passion, blogging is my hobby.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.