mysqli_select_db() 需要 2 个参数

时间:2023-03-06
本文介绍了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 个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:Php mysql pdo 查询:用查询结果填充变量 下一篇:PHP MySQLi 无法识别登录信息

相关文章