<?php
$con=mysqli_connect("localhost","xxx","xxx","xx");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = mysqli_query($con,"SELECT username, COUNT(username) AS total FROM xxxxx GROUP BY username");
$array = array();
while($fetch = mysqli_fetch_assoc($sql))
{
$array[$fetch['username']] = $fetch['total'];
}
echo '<pre>'; print_r($array);
mysqli_close($con);
?>
以下是我收到的错误
错误:::警告:mysqli_fetch_assoc()期望参数1为 mysqli_result,第20行/home/xxxxx.php中给出的布尔值
感谢您的帮助
答案 0 :(得分:0)
尝试这不是mysql而是mysqli
while($fetch = sql->fetch_assoc())
{
......