📅  最后修改于: 2020-11-27 06:11:41             🧑  作者: Mango
与MySQLi服务器建立连接后,需要选择要使用的特定数据库。这是因为MySQLi Server可能有多个数据库可用。
bool mysqli_select_db( db_name, connection );
Sr.No. | Parameter & Description |
---|---|
1 |
db_name Required – MySQLi Database name to be selected |
2 |
connection Optional – if not specified, then last opened connection by mysqli_connect will be used. |
这是显示如何选择数据库的示例。
Connecting MySQLi Server
';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
echo 'Connected failure
';
}
echo 'Connected successfully
';
mysqli_select_db( 'TUTORIALS' );
//Write some code here
mysqli_close($conn);
?>
如果成功连接并选择了数据库,则示例输出应如下所示:
Connected successfully