Home > Article > Backend Development > PHP connects to mysql database and writes data_PHP tutorial
Friends who use PHP programs know that PHP and MySQL are a very good pair. We often use it for WEB development. Now I will introduce the simplest PHP method to connect to the MySQL database and write data. Friends in need can refer to.
Principle steps
1. PHP uses mysql_connect to connect to the mysql database
2. Open the MySQL database
3. Accept page data and enter it into the specified table with PHP
4. Then use mysql_query to execute and save the sql into the database.
Connecting to mysql database is super simple as follows
The code is as follows
|
Copy code
|
|||||||||
mysql_connect("localhost","root","");//Connect MySQL
mysql_select_db("hello");//Select database
Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn Previous article:php mysqli entry application implementation_PHP tutorialNext article:php mysqli entry application implementation_PHP tutorial Related articlesSee more |