获取错误:mysqli_select_db()期望的是2个参数
警告:mysqli_select_db()期望的是2个参数,1 C中给出:\用户\根\桌面\ Web服务器\ htdocs中\ test.php的上线9
警告:mysqli_query()预计至少2个参数,1 C中给出:\用户\根\桌面\ Web服务器\ htdocs中\ test.php的上线路13
警告:mysqli_fetch_assoc()预计参数1为mysqli_result,null在第39行的C:\ Users \ root \ Desktop \ WebServer \ htdocs \ test.php中给出。
我不能注意到这个问题,新的这种,任何人都可以看到问题?
任何帮助非常感谢!
<?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>
您使用的是'mysql_'语法。您需要将连接分配给一个变量'$ mysqli = mysqli_connect(...);',然后使用它作为'select_db'和'query'函数中的第一个参数,例如'mysqli_select_db($ mysqli,“.. .. 。“);''''和'mysqli_query($ mysqli,$ sql)' – Qirel
或者,只需删除'mysqli_select_db()',并在连接中指定DB:'$ mysqli = mysqli_connect('localhost','root',' ','altislife-dev');' – Qirel