mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 个参数)
问题描述
获取错误:
警告:mysqli_select_db() 需要 2 个参数,1 个在 C:Users ootDesktopWebServerhtdocs est.php 第 9 行
Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:Users ootDesktopWebServerhtdocs est.php on line 9
警告:mysqli_query() 需要至少 2 个参数,其中 1 个在 C:Users ootDesktopWebServerhtdocs est.php 第 13 行
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:Users ootDesktopWebServerhtdocs est.php on line 13
警告:mysqli_fetch_assoc() 期望参数 1 为 mysqli_result,空值在 C:Users ootDesktopWebServerhtdocs est.php 第 39 行
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:Users ootDesktopWebServerhtdocs est.php on line 39
我没注意到这个问题,有点陌生,有人能看到问题吗?
I can't notice the problem, kind of new to this, can anyone see the problem?
非常感谢任何帮助!
<?php
//make connection
mysqli_connect('localhost', 'root', '');
//select db
mysqli_select_db('altislife-dev');
$sql="SELECT * FROM players";
$records=mysqli_query($sql);
?>
<html>
<head>
<title>Data</title>
</head>
<body>
<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>uid</th>
<th>name</th>
<th>aliases</th>
<th>playerid</th>
<th>cash</th>
<th>bankacc</th>
<th>coplevel</th>
<tr>
<?php
while($players=mysqli_fetch_assoc($records)) {
echo "<tr>";
echo "<td>".$players['uid']."</td>";
echo "<td>".$players['name']."</td>";
echo "<td>".$players['aliases']."</td>";
echo "<td>".$players['playerid']."</td>";
echo "<td>".$players['cash']."</td>";
echo "<td>".$players['bankacc']."</td>";
echo "<td>".$players['coplevel']."</td>";
echo "</tr>";
}
?>
</table>
</body>
</html>
推荐答案
做如下更正:
$conn = mysqli_connect('localhost', 'root', '');
首先必须将 select_db 中的连接变量作为第一个参数传递.如下.
the first thing that you have to pass connection variable in the select_db as first parameter. as below.
mysqli_select_db($conn,'altislife-dev');
您还必须将 mysqli_query() 中的连接变量作为第一个参数传递,如下所示.
also you have to pass connection variable in mysqli_query() as first parameter as given below.
$records=mysqli_query($conn,$sql);
这篇关于mysqli_select_db() 需要 2 个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mysqli_select_db() 需要 2 个参数
基础教程推荐
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
