title: How to count MySQL connections using PHP
body: <p>I was using following php code to check number of MySQL connections</p>
  
  <pre><code>$connection=mysql_connect("localhost","$mysql_user","$mysql_pwd");
  if (mysqli_connect_errno())
    { echo "NO CONNECTION"; }
    else
    {
  unset ($result);
  $result = mysql_list_processes($connection);
  while ($row = mysql_fetch_assoc($result)){
  $mysql_data[]=$row["db"];
  }
  mysql_free_result($result);
  $n_connections=count($mysql_data)-1;
  }
  echo "$n_connections";
  </code></pre>
  
  <p>Since mysql_connect was deprecated in PHP 5.5.0, I changed $connection with </p>
  
  <pre><code>$connection=mysqli_connect("localhost","$mysql_user","$mysql_pwd", "$mysql_db");
  </code></pre>
  
  <p>After doing this change, $n_connections is no more returning the correct value , what is wrong in the code please ?</p>
  
  <p>Thank you</p>
  
  <p>note : function mysqli_list_processes in php.net does not help, I tried it and it does not work. </p>
  
  <p>note 2: this post is not a duplicate of "How to change mysql to mysqli?" , my problem is replacing "$result = mysql_list_processes($connection);" </p>