title: Fatal Error: how to resolve a member function prepare?
body: <p>I am trying to insert values into a MySQL database called 'todo' I made a PDO connection.</p>
  
  <pre><code>    &lt;?php
  
   include_once('class.database.php');
   class ManageUsers{
       public $link;
       function __construct(){
           $db_connection = new dbConnection();
           $this-&gt;link = $db_connection-&gt;connect();
           return $this-&gt;link;
       }
       function registerUsers($username,$password,$ip_address,$time,$date){
           $query = $this-&gt;link-&gt;prepare("INSERT INTO users (username,password,ip_address,time,date) VALUES (?,?,?,?,?)");
           $values = array($username,$password,$ip_address,$time,$date);
           $query-&gt;execute($values);
           $counts = $query-&gt;rowCount();
           return $counts;
       }
   }
      $users = new ManageUsers();
      echo $users-&gt;registerUsers('bob','bob','127.0.0.1','12:00','29-02-2012');
  ?&gt;
  
  &lt;?php
  
      class dbConnection{
              protected $db_conn;
              public $db_name = 'todo';
              public $db_user = 'root';
              public $db_pass = 'password';
              public $db_host = 'localhost';
              function connect(){
                  try{
                      $this-&gt;db_conn = new PDO("mysql:host=$this-&gt;db_host;dbname=$this-&gt;db_name",$this-&gt;db_user,$this-&gt;db_pass);
                      return $this-&gt;db_conn;
                  }
                  catch(PDOException $e)
                  {
                      return $e-&gt;getMessage();
                  }
              }
      }
  ?&gt;
  </code></pre>
  
  <p>The result should be 1 - i.e. it should add one row into the database. Instead, I get the following error message. </p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Call to a member function prepare() on string in C:\xampp\htdocs\classes\class.ManageUsers.php:15 Stack trace: #0 C:\xampp\htdocs\classes\class.ManageUsers.php(24): ManageUsers->registerUsers('bob', 'bob', '127.0.0.1', '12:00', '29-02-2012') #1 {main} thrown in C:\xampp\htdocs\classes\class.ManageUsers.php on line 15</p>
  </blockquote>
  
  <p>What have I done wrong?</p>