title: PHP: Call to undefined function error in same class (file)
body: <p>I'm working on a project that uses SQL. Now I have made a function that checks the database (<strong>check_database($post)</strong>). That function should be able to be called in any other function. My other function (<strong>authenticate($post)</strong>), in the same class, calls this function. When I try the php file out, I get the following error:</p>
  
  <blockquote>
    <p><strong>Fatal error:</strong> Call to undefined function check_database() in /Applications/XAMPP/xamppfiles/htdocs/Bootstrap-Profile/Code/Controllers/AccountController.php on line <strong>91</strong></p>
  </blockquote>
  
  <p>My full code will make clear where the error is:</p>
  
  <pre><code>&lt;?php
  require_once('ConnectionController.php'); // requires
  require_once('LayoutController.php');
  
  class AccountController {
      private $connection;
  
      function __construct(){
          $server = new ConnectionController();
          $this-&gt;connection = $server-&gt;getConnection();
      }
  
      /**
       * Get account.
       * @return array|bool
       */
      function getUser($email){
          $query = "SELECT Naam, Email, Password, AccountStatus FROM Gebruiker WHERE Email=".$email.";";
  
          if($result = $this-&gt;connection-&gt;query($query)){
              return $result-&gt;fetch_assoc();
          }else{
              return false;
          }
      }
  
      /**
       * Create random string
       * @param int $length
       * @return string
       */
      function generateRandomString($length) {
          $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
          $randomString = '';
          for ($i = 0; $i &lt; $length; $i++) {
              $randomString .= $characters[rand(0, strlen($characters) - 1)];
          }
          return $randomString;
      }
  
      static function check_database($post) {
          $query = "SELECT Password, AccountStatus FROM Gebruiker WHERE Email='" .trim($post['email']). "'";
  
          if($result = $this-&gt;connection-&gt;query($query)){
  
              if (password_verify($post['password'], $result['Password'])) {
  
                  if($result['AccountStatus'] == 'Actief') {
                      $_SESSION['email']=trim($post['email']);
  
                      return true;
  
                  } else {
                      alert("warning", "&lt;b&gt;Foutmelding! &lt;/b&gt;Je account is nog niet geactiveerd! Check je mail.");
  
                      return false;
                  }
  
              } else {
                  alert("danger", "&lt;b&gt;Foutmelding! &lt;/b&gt;Het e-mailadres en wachtwoord komen niet overheen!");   
  
  
                  return false;
              }
  
          } else {
  
              alert("danger", "&lt;b&gt;Foutmelding! &lt;/b&gt;Het opgegeven e-mailadres bestaat niet!");
  
              return false;
          }
      }
  
      /**
       * Login the user in.
       * @param $account
       * @return array|bool
  
       * $email = trim($account['inputLoginEmail']);
       */
      function authenticate($post){
          if (!isset($post['email']) || empty($post['email'])) {
              alert("danger", "&lt;b&gt;Foutmelding! &lt;/b&gt;Vul een e-mailadres in!");
  
          } else if (!filter_var(trim($post['email']), FILTER_VALIDATE_EMAIL)) {
              alert("danger", "&lt;b&gt;Foutmelding! &lt;/b&gt;Ongeldig e-mailadres!");
  
          } else if (!isset($post['password']) || empty($post['password'])) {
              alert("danger", "&lt;b&gt;Foutmelding! &lt;/b&gt;Vul een wachtwoord in!");
  
          } else if (check_database($post)) {
              loadpage('profile.php');
          }
      }
  
      function __destruct(){
          $this-&gt;connection-&gt;close();
      }
  }
  </code></pre>
  
  <p>Line <strong>91</strong>:</p>
  
  <pre><code>} else if (check_database($post)) {
  </code></pre>
  
  <p>I tried many things, but I just can't find the issue. Hopefully someone can find it :)</p>