Tools, FAQ, Tutorials:
Connecting to a MySQL Server in PHP
How To Connect to MySQL from a PHP Script in PHP?
✍: FYIcenter.com
If you want access the MySQL server, you must create a connection object first by calling the mysql_connect() function in the following format:
$con = mysql_connect($server, $username, $password);
If you are connecting to a local MySQL server, you don't need to specify username and password. If you are connecting to a MySQL server offered by your Web hosting company, they will provide you the server name, username, and password.
The following script shows you how to connect to a local MySQL server, obtained server information, and closed the connection:
<?php $con = mysql_connect('localhost'); print(mysql_get_server_info($con)."\n"); print(mysql_get_host_info($con)."\n"); mysql_close($con); ?>
If you run this script, you will get something like this:
5.0.2-alpha localhost via TCP/IP
⇐ Information Needed for MySQL Connection in PHP
2016-10-20, 2393🔥, 0💬
Popular Posts:
How to make application release build with Visual Studio 2017? If you want to make a final release b...
How to use the Atom Online Validator at w3.org? w3.org feed validation service is provided at http:/...
What Is Azure API Management Service? Azure API Management as a turnkey solution for publishing APIs...
How To Change Text Fonts for Some Parts of a Paragraph? If you want to change text fonts or colors f...
Where to find tutorials on PHP language? I want to know how to learn PHP. Here is a large collection...