
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Which PHP function is used to establish MySQL database connection using PHP script?
PHP provides mysql_connect() function to open a database connection. This function takes five parameters and returns a MySQL link identifier on success or FALSE on failure. Its syntax is as follows −
Syntax
connection mysql_connect(server,user,passwd,new_link,client_flag);
Following table give us the parameters used in the syntax above −
Sr.No | Parameter & Description |
1 | Server Optional − The host name running the database server. If not specified, then the default value will be localhost:3306 |
2 | User Optional − The username accessing the database. If not specified, then the default will be the name of the user that owns the server process |
3 | Passwd Optional − The password of the user accessing the database. If not specified, then the default will be an empty password |
4 | new_link Optional − If a second call is made to mysql_connect() with the same arguments, no new connection will be established; instead, the identifier of the already opened connection will be returned |
5 | client_flags Optional − A combination of the following constants −
|
- Related Articles
- Write an example to establish MySQL database connection using PHP script?
- Which PHP function is used to disconnect from MySQL database connection?
- Which PHP function is used to select a MySQL database?
- Which PHP function is used to create a new database?
- Which PHP function is used to delete an existing database?
- Which PHP function is used to create a MySQL table?
- How can we delete a MySQL database by using PHP script?
- How can we select a MySQL database by using PHP script?
- Which PHP function is used to delete an existing MySQL table?
- Which PHP functions are used in the PHP script to fetch data from an existing MySQL table?
- Which PHP function is used to insert data into an existing MySQL table?
- Which PHP function is used to release cursor memory associated with MySQL result?
- How can we write PHP script to get the list of MySQL database?
- How can we create a new database by using PHP script?
- Which PHP function is used to give the number of rows affected by MySQL query?

Advertisements