MySQL - PHP Syntax


MySQL works very well in combination of various programming languages like PERL, C, C++, JAVA and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities.

This tutorial focuses heavily on using MySQL in a PHP environment. If you are interested in MySQL with PERL, then you can consider reading the PERL Tutorial.

PHP provides various functions to access the MySQL database and to manipulate the data records inside the MySQL database. You would require to call the PHP functions in the same way you call any other PHP function.

The PHP functions for use with MySQL have the following general format −

mysqli function(value,value,...);

The second part of the function name is specific to the function, usually a word that describes what the function does. The following are two of the functions, which we will use in our tutorial −

$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
mysqli->query(,"SQL statement");

The following example shows a generic syntax of PHP to call any MySQL function.

      <title>PHP with MySQL</title>
         $retval = mysqli - > function(value, [value,...]);
         if( !$retval ) {
            die ( "Error: a related error message" );
         // Otherwise MySQL  or PHP Statements

Starting from the next chapter, we will see all the important MySQL functionality along with PHP.

Useful Video Courses


Learn Database Design with MySQL

31 Lectures 6 hours

Eduonix Learning Solutions


Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain


Database Management Systems - MySQL

6 Lectures 3.5 hours

DATAhill Solutions Srinivas Reddy


MySQL a-z in Telugu

60 Lectures 10 hours

Vijay Kumar Parvatha Reddy


BACK-END web Development with php & MySQL

10 Lectures 1 hours

Harshit Srivastava


MySQL Database Development Mastery

25 Lectures 4 hours

Trevoir Williams