title: Fatal error: Using $this when not in object context no working properly
body: <pre><code>&lt;?php
  class Functions {
      public static function extendSql($dbhost, $dbuser, $dbpass, $dbname) {
          // making the mysql connection dynamically editable
          $mysql_connect  =   mysql_connect($dbhost, $dbuser, $dbpass)or die("Could not connect: " . mysql_error());
          $mysql_select_db =  mysql_select_db($dbname) or die(mysql_error());
      }
      public static function whileLoop($dbuser, $dbpass, $dbname, $sql, $passedData) {
          $this-&gt;extendSql($dbuser, $dbpass, $dbname);
          $results = mysql_query($sql);       
          while ($row = mysql_fetch_array($results)) {
          echo $passedData;
          }
      }
  }
  
  Functions::whileLoop("root", "", "rand", "SELECT * FROM products",
  $hello = "hi all");
  ?&gt;
  </code></pre>
  
  <p>I get the following error when I execute the above code.</p>
  
  <blockquote>
    <p>Fatal error: Using $this when not in object context in
    C:\Workspace\htdocs\Misc-2\nurbell1\core\conf\misc.php on line 13</p>
  </blockquote>
  
  <p>What am I doing wrong? Obviously, $this is referenced inside the classed context in my code.</p>