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.

Permanent link to this article: https://www.xenno.org/385/php-mysql-connection/

4 comments

Skip to comment form

  1. I love the theme on this blog. Is it downloadable anywhere?

  2. great blog man, I really admire your writing style that you are using for your posts and stuff, really hollywood…

  3. lool!! this is a great idea! 😀

Leave a Reply

Your email address will not be published.

CAPTCHA *

This site uses Akismet to reduce spam. Learn how your comment data is processed.