PHP-MySQL Connection

This post is also available in: Romanian

For some time I discovered how to make a connection between a PHP document (script) and a MySQL database. To create dynamic sites that write and read a database is needed to introduce  into a PHP file that creates a connection between the two of them. This is a used predefined PHP function mysql_connect and can be invoked whenever we need a connection to a database.
There is a need to define the following variables:
localhost = server where the database is stored. Usually this variable is denoted with localhost as the database is on the same server as the website.
mysql_user = user with access to a database that we care. This user must have write access, delete and modify the data contained in the database.
mysql_password = user password required to connect to the database.
The syntax of connection is then arranged as in the example below:

Simple connection to a MySQL Database
Simple connection to a MySQL DatabaseÂ

Note that if the connection is not made ​​an error message appears and if the connection is made ​​the message “Successfully Connected”.

I will return and other aspects of the types of connections.

4 thoughts on “PHP-MySQL Connection”

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload CAPTCHA.