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
source:php.cn
Previous article:php mysqli entry application implementation_PHP tutorial
Next article:PHP correct configuration of mysql detailed tutorial_PHP tutorial
Statement of this Website
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
Latest Articles by Author
Latest Issues
Group MySQL results by ID for looping over
I have a table with flight data in mysql. I'm writing a php code that will group and displ...
From 2024-04-06 17:27:56
0
1
406
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|