What is use of mysql_connect in php?
Complete PHP MySQL Reference Definition and UsageThe mysql_connect() function opens a non-persistent MySQL connection. Show
This function returns the connection on success, or FALSE and an error on failure. You can hide the error output by adding an '@' in front of the function name. Syntaxmysql_connect(server,user,pwd,newlink,clientflag)
Tips and NotesTip: The connection will be closed as soon as the script ends. To close the connection before, use mysql_close(). Tip: To establish a persistent MySQL connection, use mysql_pconnect() instead. Example// some codemysql_close($con); ?>
(PHP 4, PHP 5) mysql_connect — Open a connection to a MySQL Server Descriptionmysql_connect( Parametersserver The MySQL server. It can also include a port number. e.g. "hostname:port" or a path to a local socket e.g. ":/path/to/socket" for the localhost. If the PHP directive mysql.default_host is undefined (default), then the default value is 'localhost:3306'. In SQL safe mode, this parameter is ignored and value 'localhost:3306' is always used. username The username. Default value is defined by mysql.default_user. In SQL safe mode, this parameter is ignored and the name of the user that owns the server process is used. password The password. Default value is defined by mysql.default_password. In SQL safe mode, this parameter is ignored and empty password is used. new_link If a second call is made to mysql_connect() with the same arguments, no
new link will be established, but instead, the link identifier of the already opened link will be returned. The client_flags
The Return Values Returns a MySQL link identifier on success or ExamplesExample #1 mysql_connect() example
Example #2
mysql_connect() example using
Example #3 mysql_connect() example using ":/path/to/socket" syntax
$link = mysql_connect(':/tmp/mysql', 'mysql_user', 'mysql_password'); Notes
See Also
nicodenboer at yahoo dot com ¶ 10 years ago
Steve ¶ 14 years ago
VTool ¶ 5 years ago
sky dot sama dot remove dot dots at Gmail dot com ¶ 15 years ago
pepik at gmail dot cz ¶ 9 years ago
Peter Robinett ¶ 14 years ago
cory dot mawhorter gmail.com ¶ 13 years ago
jslakva at gmail dot com ¶ 15 years ago
martin ¶ 15 years ago
Ignacio Casinelli Esviza ¶ 14 years ago
= @mysql_connect($server,$user,$pass); amn -at- frognet.net ¶ 19 years ago
avinc@live,hk ¶ 11 years ago
tpl99 at yandex dot ru ¶ 12 years ago
Harouk ¶ 11 years ago
martinnitram at excite dot com ¶ 18 years ago
Graham_Rule at ed dot ac dot uk ¶ 15 years ago
Graham_Rule at ed dot ac dot uk ¶ 19 years ago
aeolianmeson at blitzeclipse dot com ¶ 14 years ago
abelcheung at gmail dot com ¶ 12 years ago
angelo [at] mandato 15 years ago
GetMyConnection() arithmetric at gmail dot com ¶ 14 years ago
bimal at sanjaal dot com ¶ 11 years ago
brinca at substancia dot com ¶ 15 years ago
trev at dedicate dot co dot uk ¶ 10 years ago
chaoscontrol_hq at yahoo dot com ¶ 18 years ago
rui dot batista at netcabo dot pt ¶ 16 years ago
yangqingrong at wudimei dot com ¶ 9 years ago
pascalxusNOSPAM at yahoo dot com ¶ 14 years ago
Anonymous ¶ 17 years ago
Contact at LinuxIntro dot com ¶ 13 years ago
sholland at napervillegi dot com ¶ 12 years ago
david dot schueler at wapkamera dot de ¶ 13 years ago
dan at novapulsar dot com ¶ 14 years ago
?>
php at lanar dot com dot au ¶ 10 years ago
bmagilavy at avalon-internet dot com ¶ 14 years ago
What is difference between mysql_connect and Mysql_pconnect?Mysql_connect() opens a new connection to the database while mysql_pconnect() opens a persistent connection to the database. This means that each time the page is loaded mysql_pconnect() does not open the database.
Which function can use to connect database on server rather than use mysql_connect ()?The connect() / mysqli_connect() function opens a new connection to the MySQL server.
Is mysql_connect deprecated?This extension was deprecated in PHP 5.5. 0, and it was removed in PHP 7.0.
How do you connect MySQL database with PHP?Create Database.. Create a Folder in htdocs.. Create Database Connection File In PHP.. Create new php file to check your database connection.. Run it.. |