Home  >  Article  >  Backend Development  >  How can I know which database is currently being used using code?

How can I know which database is currently being used using code?

WBOY
WBOYOriginal
2016-07-29 09:10:301547browse

One day, an error suddenly occurred in the production environment. The exception thrown was probably that a certain table did not exist. I thought at the time, how could it not exist? Could it be that it was attacked by hackers? So I just want to know which database is currently used

<span>$current_database</span> = <span>mysql_query</span>("SELECT DATABASE()") or <span>die</span>(<span>mysql_error</span>());<br><span>echo</span><span>mysql_result</span>(<span>$current_database</span>,0);

The above introduces how to use code to know which database is currently being used? , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

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:Make learning a habitNext article:Make learning a habit