what is the best function that can be used to connect to
mysql database and in what cases that we can use below
functions ?

1. mysql_connect()

2. mysql_pconnect()

please give your answer with all pros and cons

Answer Posted / p.sivasankar

1>>mysql_connect() — Open a connection to a MySQL Server

Description:
resource mysql_connect ([ string $server [, string
$username [, string $password [, bool $new_link [, int
$client_flags ]]]]] )
Opens or reuses a connection to a MySQL server

2>>mysql_pconnect — Open a persistent connection to a MySQL
server

Description:
resource mysql_pconnect ([ string $server [, string
$username [, string $password [, int $client_flags ]]]] )

Establishes a persistent connection to a MySQL server.

mysql_pconnect() acts very much like mysql_connect() with
two major differences.

First, when connecting, the function would first try to
find a (persistent) link that's already open with the same
host, username and password. If one is found, an identifier
for it will be returned instead of opening a new
connection.

Second, the connection to the SQL server will not be closed
when the execution of the script ends. Instead, the link
will remain open for future use (mysql_close() will not
close links established by mysql_pconnect()).

This type of link is therefore called 'persistent'

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is better mysql or sql?

525


What is csrf token in php?

548


what is constructor

1065


What is difference between require_once(), require(), include()?

515


How many types of functions are there in php?

593






What is active record in php?

479


What is the difference between $var and $$var?

548


What is a stored procedure in mysql?

529


Tell me how a constant is defined in a php script?

476


Explain the difference between session and cookies in php?

505


How do I install php and apache on windows 10?

508


What language is similar to php?

551


What is the main difference between require() and include()?

476


What are the difference between array_keys() and array_key_exists() in php?

537


What PHP stands for?

568