MySQL PHP Syntax
MySQL can be applied to various languages, including PERL, C, C++, JAVA, and PHP. Among these, MySQL is most widely used in PHP web development.
In this tutorial, most of our examples use PHP. If you want to learn about MySQL's application in PHP, you can visit our Introduction to Using MySQL in PHP.
PHP provides multiple ways to access and manipulate MySQL database records:
The format for PHP MySQL functions is as follows:
mysqli_function(value, value, ...);
mysqli_connect($connect);
mysqli_query($connect, "SQL statement");
mysqli_fetch_array();
mysqli_close();
The following example demonstrates the syntax for calling MySQL functions in PHP:
Example (MySQLi)
<?php
$retval = mysqli_function(value, [value, ...]);
if (!$retval) {
die("Relevant error information");
}
// Other MySQL or PHP statements
?>
Starting from the next chapter, we will learn more about MySQL functional functions.