MySQL and PHP

PHP and MySQL work's together most of the time and is the default SQL engine of Linux (next to PostSQL which is also shipped along with MySQL). MySQL is the most popular SQL engine for Linux and exist in other platform as well. Just like MySQL, PHP too itself is a multi platform application.

Topic listed here-in are the most basic and/or the most commonly used combination needed to work with MySQL and PHP and as follows:

Open Connection

To connect to an existing Database and access the tables with-in so, the said User must have the proper grant access to the said Databases:

$query2 - this holds the standard SQL update statement that will update the users table

$row[0] - points to the first field from the $result variable

Magic Quotes and Escape Strings

ex.:

function esc_data( $data ) {

global $dbc;

IF (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); }

return mysql_real_escape_string($data, $dbc);

}

mysql_real_escape_string

will automatically escapte problematic characters for text entered in forms and requires a connection ($dbc).

requires two(2) basic parameters; the subject data ($data) and the connection ($dbc) and returns only characters that are readable

ini_get

returns FALSE, when there is no need to strip any existing slashes and it accepts a single parameter (which is the string to be search)

Last Insert

To fetch the last insert ID or the auto incremental value assign after an entry had been inserted (added) into the selected active Table. Please note that this statement must be executed right after the INSERT SQL command had been executed in order to get the proper value.