Home >Backend Development >PHP Problem >How to delete the database corresponding to the database in php

How to delete the database corresponding to the database in php

藏色散人
藏色散人Original
2021-11-10 09:39:271818browse

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.

How to delete the database corresponding to the database in php

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.

How to delete the database corresponding to the database in php

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.

How to delete the database corresponding to the database in php

In the test.php file, create a mysql database connection using the user and password through the mysql_connect() function.

How to delete the database corresponding to the database in php

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.

How to delete the database corresponding to the database in php

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.

How to delete the database corresponding to the database in php

Open the test.php file in the browser to view the results.

How to delete the database corresponding to the database in php

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!

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:How to delete data in phpNext article:How to delete data in php