What to do if database selection fails in php

藏色散人
Release: 2023-03-14 15:12:01
Original
2008 people have browsed it

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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!