Home >Backend Development >PHP Problem >How to delete the database corresponding to the database in php
php method to delete the database corresponding to the database: 1. Create a new php file; 2. Create a mysql database connection; 3. Create a sql statement to delete the database my_db; 4. Use the mysql_query() function to execute sql statement to delete the database.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How does php delete the database corresponding to the database?
Delete the specified mysql database in php
Create a new php file named test.php to explain how to use it in php Delete the specified mysql database.
In the test.php file, use the header() method to set the encoding format of the page to utf-8 to avoid outputting Chinese garbled characters.
In the test.php file, create a mysql database connection using the user and password through the mysql_connect() function.
In the test.php file, create a SQL statement "drop database my_db" to delete the database my_db, and save it in the $sql variable.
In the test.php file, use the mysql_query() function to execute the sql statement to delete the database my_db, and then use the if statement to determine the result of the deletion.
Open the test.php file in the browser to view the results.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to delete the database corresponding to the database in php. For more information, please follow other related articles on the PHP Chinese website!