Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

MariaDB PHP syntax


May 16, 2021 MariaDB



MariaDB works well with a variety of programming languages and frameworks (e.g. PHP, C#, JavaScript, Ruby on Rails, Django, etc.). P HP remains the most popular language of all available languages because of its simplicity and historical footprint. T his guide will focus on PHP in collaboration with MariaDB.

PHP provides a range of features using the MySQL database. T hese functions perform tasks similar to accessing it or performing operations, and they are fully compatible with MariaDB. J ust call these functions, just like any other PHP function.

The PHP function you will use for MariaDB conforms to the following format -

mysql_function(value,value,...);

The second part of the function specifies its operation. T he two features used in this guide are as follows -

mysqli_connect($connect);
mysqli_query($connect,"SQL statement");

The following example demonstrates the general syntax of PHP calls to Maria DB functions -

<html>
   <head>
      <title>PHP and MariaDB</title>
   </head>

   <body>
      <?php
         $retval = mysql_function(value, [value,...]);
      
         if( !$retval ) {
            die ( "Error: Error message here" );
         }
         // MariaDB or PHP Statements
      ?>
   </body>
</html>

In the next section, we'll use the PHP function to examine the basic tasks of MariaDB.