php mysql connect | using mysql_connect function to establish DB connection

Establishing DB connection with mysql_connect

PHP provides built-in function mysql_connect to establish database connection with MySQL database. See the syntax below

connection mysql_connect(server,user,passwd,new_link,client_flag);

We have assumed that you have created a database with:

database name = testdb

user name = tesuser

password = testpassword

at your local system.

In that case:

DB host = “localhost”

Connecting to MySQL Example

Connecting to Database

After establishing connection to MySQL, its time to connect to working database, testdb





MySQL Connected successfully

Connected to Database

Now as MySQL is connected and database is connected/chosen as well, its time to insert, update and delete operations at tables of database.

Was this article helpful?

Related Articles

Leave A Comment?