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, 918👍, 0💬
Can You Copy an Array in PHP? You can create a new array by copying an existing array using the assi...
How the Values Are Ordered in an Array in PHP? PHP says that an array is an ordered map. But how the...
How To Generate and Process a Form with the Same Script in PHP? In previous exercises, a Web form is...
How to install .NET Framework in Visual Studio Community 2017? I have the Visual Studio Installer in...
How To Select an Exiting Database in PHP? The first thing after you have created a connection object...