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



what is the best function that can be used to connect to mysql database and in what cases that we c..

Answer / 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

More PHP Interview Questions

What is php in simple words?

0 Answers  


What is the difference between explode and split?

0 Answers  


How to copy a file?

0 Answers  


Dear Sir, i am a frasher and now i got a job offer from AentteQ Software Technologies for PHP developer.. so i am in confusion that is PHP correct for my carrer or i shud choose other then php for my carrer...plz suggest me

4 Answers   NIIT,


Why echo is faster than print in php?

0 Answers  


Explain Magento's autoload functionality and how to instantiate classes? What is the process you take when theming a store? Talk about Magento collections and how you use them?

0 Answers  


Which is the best method to fetch the data from mysql? 1.mysql_fetch_array() 2.mysql_fetch_object() 3.mysql_fetch_row() 4.mysql_fetch_assoc()

6 Answers  


When do you use define() and when do you use const. What are the main differences between those two?

0 Answers  


Explain what is the function file_get_contents() usefull for?

0 Answers  


Is empty java?

0 Answers  


What is advanced php programming?

0 Answers  


How to open a file in php?

0 Answers  


Categories