MySQL

mysql is both the name of a PHP extension that provides the interface to interact with the MySQL database, and the database itself. mysql is also known as mysqli, as the original PHP extension has been improved, over the years. All three names may be interchangeable, depending on the context.

mysqli defines functions, constants and classes. It has been upgraded to use objects instead of resources.

mysql also applies to MariaDB, which is a drop-in replacement of MySQL.

<?php

    // Connecting, selecting database
    $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
        or die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    mysql_select_db('my_database') or die('Could not select database');

    // Performing SQL query
    $query = 'SELECT * FROM my_table';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());

    // Printing results in HTML
    echo "<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo "\t<tr>\n";
        foreach ($line as $col_value) {
            echo "\t\t<td>$col_value</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";

    // Free resultset
    mysql_free_result($result);

    // Closing connection
    mysql_close($link);

?>

Documentation

See also MySQL home, MariaDB home and An Introduction to PHP and MySQL(Inserting and Fetching from MySQL).

Related : mysqli, Graph Database, Oracle, Relational DataBase Management System (RDBMS), SQL Database, Linux Apache Mysql PHP (LAMP), Linux Nginx Mysql PHP (LEMP)