title: mysql count not working correctly?
body: <p>I know PHP's ext/mysql API is outdated and i shouldn't be using it, however this is not my question, my question is i have this piece of code which counts the id's in my table, it was working and now its not, for no reason as far as i can see.</p>
  
  <p>can someone please show me where i am going wrong with the code thanks.</p>
  
  <p>im getting this error:</p>
  
  <pre><code>Warning: mysql_query() expects parameter 2 to be resource, null given in /Applications/XAMPP/xamppfiles/htdocs/site.com/includes/functions.php on line 2023
  Database query failed
  </code></pre>
  
  <p>my table:</p>
  
  <p>ptb_friend_requests</p>
  
  <pre><code>id | from_user_id | to_user_id | read_request | approved_request | delete_request
  
  1         2              1            0                 0                  0
  </code></pre>
  
  <p>mysql code:</p>
  
  <pre><code>function check_new_friends() {
          global $connection;
          global $_SESSION;
          $query = "SELECT COUNT(id) FROM ptb_friend_requests WHERE to_user_id=".$_SESSION['user_id']." AND deleted_request='0' AND read_request='0' AND approved_request='0' AND from_user_id != '0'";
          $check_new_friends_set = mysql_query($query, $connection);
          confirm_query($check_new_friends_set);
          return $check_new_friends_set;      
      }
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>$check_profile_views_set = check_profile_views();
  while ($newf = mysql_fetch_array($check_profile_views_set)) {
  
  echo "&lt;div class=\"friend-notify\"&gt;". $newf['COUNT(id)'] ."&lt;/div&gt;";
  
  //$check_new_duos_set = check_new_escort_duos(); while ($newd = mysql_fetch_array($check_new_duos_set)) { ?&gt;
  
  &lt;? echo "". $newf['COUNT(id)'] .""; ?&gt;&lt;? } ?&gt;
  </code></pre>