title: PHP PDO - INSERT INTO with bindParam does not work
body: <p>I stucked at this little piece of code:</p>
  
  <pre><code>$fruit_object = new fruit(1234, 'apple', 'red apple');    
  
  try {
      $dbh = new PDO('mysql:host=localhost;charset=utf8;dbname=database', 'user', 'password');
      $exc = $dbh-&gt;prepare("INSERT INTO fruit( type, name) VALUES (:type, :name);");                               
      //$exc-&gt;bindParam(':id',   $fruit_object-&gt;id,   PDO::PARAM_INT);
      $exc-&gt;bindParam(':type', $fruit_object-&gt;type, PDO::PARAM_STR);
      $exc-&gt;bindParam(':name', $fruit_object-&gt;name, PDO::PARAM_STR);
      $exc-&gt;execute();
      $dbh = null;
      $exc = null;
  } catch (PDOException $e) {
      //this function just do an echo with static content
      $this-&gt;error_database($e);
      $dbh = null;
      $exc = null;
      die();
  }
  </code></pre>
  
  <p>I already used PDO for SELECTING things from my database, but with INSERTING something, it does not work. The user has the access to only INSERT stuff - i already tried that on my backend successfully.</p>
  
  <p>So here is the error:</p>
  
  <pre><code>Fatal error: Uncaught Error: Cannot access private property fruit_object::$type
  </code></pre>
  
  <p>This is my fruit_object class:</p>
  
  <pre><code>&lt;?php
  
  
  class fruit
  {
  private $id;
  private $type;
  private $name;
  
  function __construct($id, $type, $name)
  {
      $this-&gt;id = $id;
      $this-&gt;type = $type;
      $this-&gt;name = $name;
  
  }
  
  function __toString()
  {
      return $this-&gt;name;
  }
  }
  </code></pre>
  
  <p>For martin:</p>
  
  <pre><code>INSERT INTO fruit (id, type, name) VALUES (DEFAULT, 'apple', 'red apple');
  </code></pre>
  
  <p>My database is running on a MySQL server - is this the cause ? Do i have to work with questionmarks (?)?</p>
  
  <p>Thank you, Louis</p>