php - Error in query - Warning: mysqli_fetch_assoc() -


<?php $con=mysqli_connect("localhost","xxx","xxx","xx"); // check connection if (mysqli_connect_errno())   {   echo "failed connect mysql: " . mysqli_connect_error();   }  $sql = mysqli_query($con,"select username, count(username) total xxxxx group username");  $array = array(); while($fetch = mysqli_fetch_assoc($sql)) {     $array[$fetch['username']] = $fetch['total']; }  echo '<pre>'; print_r($array);  mysqli_close($con); ?> 

below error receiving

error::: warning: mysqli_fetch_assoc() expects parameter 1 mysqli_result, boolean given in /home/xxxxx.php on line 20

thanks help

try not mysql mysqli

while($fetch = sql->fetch_assoc()) { ...... 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -