警告:mysqli_select_db() 需要 2 个参数,1 个给定 [英] Warning: mysqli_select_db() expects exactly 2 parameters, 1 given

查看:56
本文介绍了警告:mysqli_select_db() 需要 2 个参数,1 个给定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个教程,其中作者没有更新其内容以反映 PHP 文档中的更改.无论如何,我需要知道要求我提供什么参数.我已经检查过所有东西都井然有序,但我真的不知道我应该提供什么.这是我所拥有的:

I'm doing a tutorial in which the author has not updated his content to reflect changes in the PHP documentation. Anyways, I need to know what is parameter is being asked of me to provide. I've checked that all things are in order, but I literally don't know what I'm supposed to provide. Here's what I have:

Connects.php

<?php
$connect_error = 'Sorry, we\'re experiencing connection issues.';
$con = mysqli_connect('localhost', 'root', 'PwdSQL5');
mysqli_select_db('phpcadet') or die($connect_error);
?>

但我得到了错误:

警告:mysqli_select_db() 需要 2 个参数,1 个在 C:...

Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:...

推荐答案

mysqli_select_db() 应该有 2 参数,连接链接和数据库名称 -

mysqli_select_db() should have 2 parameters, the connection link and the database name -

mysqli_select_db($con, 'phpcadet') or die(mysqli_error($con));

在 die 语句中使用 mysqli_error准确地告诉你什么是错误的,而不是一般的错误消息.

Using mysqli_error in the die statement will tell you exactly what is wrong as opposed to a generic error message.

这篇关于警告:mysqli_select_db() 需要 2 个参数,1 个给定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆