title: Uncaught argumentCountError
body: <p>I am having error here it says that i have uncaught arugmentcount error but I am just following the tutorial it has no error but when I do it has. I checked all the possible errors even the spelling and semi colons   </p>
  
  <blockquote>
    <p>Fatal error: Uncaught ArgumentCountError: Too few arguments to function database::bind(), 1 passed in C:\xampp\htdocs\ooplogin\index.php on line 15 and at least 2 expected in C:\xampp\htdocs\ooplogin\classes\database.php:35<br>
    Stack trace:<br>
    #0 C:\xampp\htdocs\ooplogin\index.php(15): database->bind(':title, :$title')<br>
    #1 {main} thrown in C:\xampp\htdocs\ooplogin\classes\database.php on line 35</p>
  </blockquote>
  
  <p>this is my code example for <code>index.php</code></p>
  
  <pre><code>&lt;?php
  require 'classes/database.php';
  
  $database = new database;
  
  $database-&gt;query('SELECT * FROM post');
  $rows = $database-&gt;resultset();
  
  $post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
  
  if($post['submit']){
      $title = $post['title'];
      $body = $post['body'];
      $database-&gt;query('INSERT INTO post(title, body) VALUE (:title, :body)');
      $database-&gt;bind(':title, :$title');
      $database-&gt;bind(':body, $body');
      $database-&gt;execute();
      if($database-&gt;lastInsertId()){
          echo '&lt;p&gt;Post Added!&lt;/p&gt;' ;
      }
  
  }
  
  ?&gt;
      &lt;h1&gt;Add Post&lt;/h1&gt;
      &lt;label&gt;Post Title&lt;/label&gt;
      &lt;br /&gt;
      &lt;form method="post" action=" &lt;?php $_SERVER['PHP_SELF']; ?&gt;"&gt;
          &lt;input type="text" name="title" placeholder="Add Title.."&gt;
          &lt;br /&gt;
          &lt;label&gt;Post Body&lt;/label&gt;
          &lt;br /&gt;
          &lt;textarea name="body" cols="30" rows="10"&gt;&lt;/textarea&gt;
          &lt;br&gt;
          &lt;input type="submit" name="submit" value="submit"&gt;
      &lt;/form&gt;
      &lt;h1&gt;POSTS&lt;/h1&gt;
      &lt;div&gt;
          &lt;?php foreach($rows as $row) : ?&gt;
          &lt;div&gt;
              &lt;h3&gt;
                  &lt;?php echo $row['title']; ?&gt;
              &lt;/h3&gt;
              &lt;p&gt;
                  &lt;?php echo $row['body']; ?&gt;
              &lt;/p&gt;
          &lt;/div&gt;
          &lt;?php endforeach; ?&gt;
      &lt;/div&gt;
  
  
  and for classes/database.php`
  
      &lt;?php
  
  class database{
      private $host = 'localhost';
      private $user = 'root';
      private $password = '';
      private $dbname = 'oopdtbs';
  
      private $dbh;
      private $error;
      private $stmt;
  
  
  
      public function __construct(){
          // Set DSN
          $dsn = 'mysql:host='. $this-&gt;host . ';dbname='. $this-&gt;dbname;
          // Set Options
          $options = array(
              PDO::ATTR_PERSISTENT        =&gt; true,
              PDO::ATTR_ERRMODE       =&gt; PDO::ERRMODE_EXCEPTION
          );
          // Create new PDO
          try {
              $this-&gt;dbh = new PDO($dsn, $this-&gt;user, $this-&gt;pass, $options);
          } catch(PDOEception $e){
              $this-&gt;error = $e-&gt;getMessage();
          }
      }
  
      public function query($query){
          $this-&gt;stmt = $this-&gt;dbh-&gt;prepare($query);
      }
  
      public function bind($param, $value, $type = null){
          if(is_null($type)){
              switch(true){
                  case is_int($value):
                      $type = PDO::PARAM_INT;
                      break;
                  case is_bool($value):
                      $type = PDO::PARAM_BOOL;
                      break;
                  case is_null($value):
                      $type = PDO::PARAM_NULL;
                      break;
                      default:
                      $type = PDO::PARAM_STR;
              }
          }
          $this-&gt;stmt-&gt;bindValue($param, $value, $type);
      }
  
      public function execute(){
          return $this-&gt;stmt-&gt;execute();
      }
  
      public function lastInsertId(){
          $this-&gt;dbh-&gt;lastInsertId();
      }
  
      public function resultset(){
          $this-&gt;execute();
          return $this-&gt;stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
      }
  }
  </code></pre>