Connecting to a MySQL Server in PHP
How To Connect to MySQL from a PHP Script in PHP?
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
2016-10-20, 1337👍, 0💬
How to create Hello-3.0.epub with WinRAR? I have all required files to create Hello-3.0.epub. To cre...
Where to find tutorials on introduction of EPUB 2.0.1 Specification? Here is a list of tutorials to ...
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...
What Is HTML? HTML (HyperText Markup Language) is the standard markup language for creating Web page...
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard i...