title: PHP - Call to undefined method database::real_escape_string()
body: <p>I have searched and tried all the suggestions that Stakeoverflow suggested to me, But none was working for me. I have 2 php files (add_new_page.php, sanitise.php) I' am getting this error on "sanitise.php" function "escape".</p>
  
  <blockquote>
    <p>PHP - Call to undefined method database::real_escape_string()</p>
  </blockquote>
  
  <p>I can't seem to find out what I' am doing wrong in my function escape. Any help will be really appreciated. My deadlines are very close and I need to get this working soon as possible. Below are the codes of my 2 working files.</p>
  
  <p><strong>Database Connection</strong></p>
  
  <pre><code>$db = new database($db_host, $db_user, $db_pass, $db_name); 
  </code></pre>
  
  <p><strong>add_new_page.php</strong></p>
  
  <pre><code>require_once "../classes/classes.php"; 
  if(isset($_POST["txtpagetitle"])){
      $txtpagetitle = $_POST["txtpagetitle"];
      $txtbrowsertitle = $_POST["txtbrowsertitle"];
      $txtpagecontent = $_POST["txtpagecontent"];
  
      $txtpagetitle       = trimmer($txtpagetitle);
      $txtbrowsertitle    = trimmer($txtbrowsertitle);
      $txtbrowsertitle    = trimmer($txtbrowsertitle);
  
      $txtpagetitle       = escape($txtpagetitle, $db);//Calling escape function
      $txtbrowsertitle    = escape($txtbrowsertitle, $db);//Calling escape function
      $txtbrowsertitle    = escape($txtbrowsertitle, $db);//Calling escape function
  
      $txtpagetitle_required = required($txtpagetitle);
      $txtbrowsertitle_required = required($txtbrowsertitle);
  
          if($txtpagetitle_required == false){
              echo "Page Title is required...";
              return false;
          }       
  }
  </code></pre>
  
  <p><strong>sanitise.php</strong></p>
  
  <pre><code>// Escape all characeters - I' am getting the error here...
      function escape($field){
          global $db;
          return $db-&gt;real_escape_string($field);
      }
  </code></pre>