title: Getting error: Use of undefined constant num - assumed 'num'
body: <p>I'm following a php pagination <a href="http://papermashup.com/easy-php-pagination/" rel="nofollow noreferrer">tutorial</a> that uses MYSQL but I use MYSQLI object oriented all around my site. This is causing some errors..</p>
  
  <p>For this part..</p>
  
  <pre><code>$sql = "SELECT COUNT(*) as num FROM categories";
  $total_pages = $connection-&gt;query($sql) or die(mysqli_error($connection)); 
  $total_pages = $total_pages['num'];
  </code></pre>
  
  <p>I get <em>Fatal error: Cannot use object of type mysqli_result as array</em>.. on the last line</p>
  
  <p>so I switched it to</p>
  
  <pre><code>$sql = "SELECT COUNT(*) as num FROM categories";
  $total_pages = $connection-&gt;query($sql) or die(mysqli_error($connection)); 
  $row = $total_pages-&gt;fetch_assoc();
  $total_pages  = $row[num];
  </code></pre>
  
  <p>and now I get <em>Use of undefined constant num - assumed 'num'</em> ..on the last line.</p>
  
  <p>At this point, I'm not sure what else to do. Can someone please help?</p>