title: Call to undefined function query() when it is defined
body: <p>I have searched through similar questions and can't find the answer, though I am a beginner so may have missed it.</p>
  
  <p>I am trying to call the <code>review_create()</code> function I have included the <code>reviews.php</code> which contains this function. However, I am getting the error </p>
  
  <blockquote>
    <p>Fatal error: Call to undefined function query() in C:\xampp\htdocs\cafe\review.php</p>
  </blockquote>
  
  <p>The PHP for user_pages.php:</p>
  
  <pre><code>&lt;?php
          require_once 'review.php';
          require_once 'cafe.php';
          require_once 'logged_in.php';
  
          $RATING_MAP = array('5' =&gt; 'Excellent', '4' =&gt; 'Good', '3' =&gt; 'Ok', '2' =&gt; 'Bad', '1' =&gt; 'Awful', '0' =&gt; '---');
          $error = array();//holds multiple errors
          $id = $rating = $review = $action = '';
          $self = $_SERVER['PHP_SELF'];
  
          if (isset($_REQUEST['action'])) {
              $action = $_REQUEST['action'];
          }
  
          if ($action == 'delete') {
              if (isset($_REQUEST['id'])) {
                  review_delete($_REQUEST['id'], $error);
              } else {
                  $error[count($error)] = "Cannot delete the review, missing ID!";
              }
          } 
  
          elseif ($action == 'create') {
              if ((isset($_REQUEST['rating']))
                      &amp;&amp; (isset($_REQUEST['review'])
                              &amp;&amp; (isset($_REQUEST['review_cafe'])))) {
                  $rating = $_REQUEST['rating'];
                  $review = $_REQUEST['review'];
                  $review_cafe = $_REQUEST['review_cafe'];
                  if ($rating == '---' or $review == '' or $review_cafe == '') {
                      $error[count($error)] = "You must provide a cafe, rating and review!";
                  } else {
                      review_create($review_cafe, $rating, $review, $error);
                  }
                      }
              else {
                  $error[count($error)] = "Unable to create review, missing parameters!";
              }
          }
  ?&gt;
  </code></pre>
  
  <p>The PHP for reviews.php:</p>
  
  <pre><code>&lt;?php
      require_once "sql.php";
  
      function review_create($review_cafe, $rating, $review, &amp;$error) {
          $query = "INSERT INTO Reviews (cafe, rating, review) VALUES (". "'$review_cafe', $rating, '$review');";
          $success = query($query, $error);
          return $success;
  
      }
  ?&gt;
  </code></pre>
  
  <p>Here is sql.php where $query is defined:</p>
  
  <pre><code>&lt;?php //sql.php
  require_once "sql_constants.php";
  
  class Sql {
  
  private static $connection = false;
  private static $error;  // holds the last error.
  
  static function getConnection() {
      if (!Sql::$connection) {
          Sql::setConnection(mysqli_connect(SQLHOST, SQLUSER, SQLPASSWORD, HOSTDB));
          if (!Sql::$connection) {
              Sql::setConnection(false);
              Sql::setError("Could not connect...");
          }
      }
      return Sql::$connection;
  }
  
  private static function setConnection($iConnection) {
      Sql::$connection = $iConnection;
  }
  
  private static function setError($iError) {
      Sql::$error = $iError;
  }
  
  static function getError() {
      return Sql::$error;
  }
  
  static function query($query) {
      $result = false;
      Sql::setError(false); // reset the error
      if ($link = Sql::getConnection()) {
          $result = mysqli_query($link, $query);
          if (!$result) 
              Sql::setError(mysqli_error($link));
  
          }
          return $result;
      }
  
      static function getInsertID() {
      // Returns the last id automatically inserted into the
      // database.
          return mysqli_insert_id(Sql::getConnection());
      }
  
      }
  ?&gt;
  </code></pre>
  
  <p>Cheers
  James</p>