![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −
|
Advertisements