Home >Backend Development >PHP Problem >What to do if database selection fails in php

What to do if database selection fails in php

藏色散人
藏色散人Original
2021-12-22 10:00:262113browse

Solution to failed database selection in php: 1. Check mysql_select_db and mysqli_select_db; 2. Modify the order of incoming parameters of the two connection methods.

What to do if database selection fails in php

The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

What should I do if the database selection fails in php?

"Failed to select database" occurs when PHP connects to the database?

When PHP connects to the database:

There is no problem connecting to the database with mysqli_connect, but there is always an error when using mysqli_select_db ! Puzzled.

After careful observation of mysql_select_db and mysqli_select_db, I found that

The incoming parameters of mysql_select_db are ($databaseName,$query);

The incoming parameters of mysqli_select_db The parameters are ($query,$databaseName);

At this point, it turns out that the order of the parameters passed in the two connection methods is not the same, so the selection failed.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if database selection fails 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:What is 403 error in php?Next article:What is 403 error in php?