


PHP connects to the database and dynamically displays database records_PHP tutorial
Jul 13, 2016 pm 05:16 PMThis article will introduce a good introductory example of PHP mysql to PHP beginners. We connect to the database and display the record examples in the database. Friends can refer to it.
Connect to a MySQL database
Before you can access and process data in the database, you must create a connection to the database.
In PHP, this task is accomplished through the mysql_connect() function.
Grammar
mysql_connect(servername,username,password);
In the example below, we store the connection in a variable ($con) for later use in the script. If the connection fails, the "die" part will be executed:
The code is as follows
|
Copy code
|
||||
$con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } |

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How to fix mysql_native_password not loaded errors on MySQL 8.4
