Friday, 8 January 2016

Run the query MySQL from PHP (mysql_query)

Mysql_query () function requires two arguments, where the first argument is filled with MySQL query, and the second argument is filled with the results of the connection link mysql_connect () function. The second argument is optional.

Here is the basic format of writing mysql_query () function in PHP:

$result = mysql_query("query_mysql",[$link_koneksi_mysql]);

Stopping MySQL PHP connection with mysql_close ()


PHP with MySQL connection will be terminated automatically when the program execution is completed, which is when the PHP page is finished processing, so we do not need to manually menghentikanya.

But if you want to stop the connection with MySQL when the program is running PHP, PHP provides a function mysql_close (). This function takes one argument which is filled with the fruit of the variable 'link connection' results call mysql_connect () function. This connection variable is optional, and if omitted, PHP will use the last mysql connection.

PHP connection with MySQL (mysql_connect)


To make a connection between PHP with MySQL using mysql extension, PHP provides mysql_connect () function.
This function is described as a way to log into the MySQL ServerMysql_connect ().Function requires three arguments, and return value of the function in the form of 'variable' connection to MySQL.
Here is the basic format of writing the function mysql_connect ():
$link = mysql_connect(’mysql_host’, 'mysql_user', 'mysql_password');