title: Fatal error: Call to a member function prepare() on string
body: <p>wait please, dont post this as a duplicate because ive done research and tried everything but cant get it to work, i keep getting this error "Fatal error: Call to a member function prepare() on string in C:\wamp64\www\Etego\dbcontroller.php on line 63" i am trying to get people on my inscription form not to use the same email twice, thanks in advance! heres the code :</p>
  
  <p>dbcontroller.php</p>
  
  <pre><code>&lt;?php
  class DBController {
      public $host = "localhost";
      public $user = "root";
      public $password = "";
      public $database = "members";
      public $conn;
  
      function __construct() {
          $this-&gt;conn = $this-&gt;connectDB();
      }
  
      function connectDB() {
          $conn = mysqli_connect($this-&gt;host,$this-&gt;user,$this-&gt;password,$this-&gt;database);
          return $conn;
      }
  
      function runQuery($query) {
          $result = mysqli_query($this-&gt;conn,$query);
          while($row=mysqli_fetch_assoc($result)) {
              $resultset[] = $row;
          }        
          if(!empty($resultset))
              return $resultset;
      }
  
      function numRows($query) {
          $result  = mysqli_query($this-&gt;conn,$query);
          $rowcount = mysqli_num_rows($result);
          return $rowcount;    
      }
  
      function updateQuery($query) {
          $result = mysqli_query($this-&gt;conn,$query);
          if (!$result) {
              die('Invalid query1: ' . mysqli_error($this-&gt;conn));
          } else {
              return $result;
          }
      }
  
      function insertQuery($query) {
          $result = mysqli_query($this-&gt;conn,$query);
          if (!$result) {
              die('Invalid query2: ' . mysqli_error($this-&gt;conn));
          } else {
              return $result;
          }
      }
  
      function deleteQuery($query) {
          $result = mysqli_query($this-&gt;conn,$query);
          if (!$result) {
              die('Invalid query3: ' . mysqli_error($this-&gt;conn));
          } else {
              return $result;
          }
      }
  }
  
  
  /* Email already exists */
  /*line 63*/       
  $db = new DBController; 
  $db-&gt;database-&gt;prepare("SELECT * FROM members WHERE email = ?");
  $reqemail-&gt;execute(array($email));
  $emailexist = $reqemail-&gt;rowCount();
  if($emailexist == 0) {
  } else {
      $error_message = "Email already exists";
  }
  //end of email existance
  ?&gt; 
  </code></pre>
  
  <p>index2.php</p>
  
  <pre><code>&lt;!-- how to make members when login "keep me signed in"  and ho to make users 13+ with the date input --&gt;
  
  &lt;?php
  if(!empty($_POST["register-user"])) {
      /* Form Required Field Validation */
      foreach($_POST as $key=&gt;$value) {
          if(empty($_POST[$key])) {
          $error_message = "All Fields are required";
          break;
          }
      }
      /* Password Matching Validation */
      if($_POST['password'] != $_POST['confirm_password']){ 
      $error_message = 'Passwords should be same&lt;br&gt;'; 
      }
  
      /* Email Validation */
      if(!isset($error_message)) {
          if (!filter_var($_POST["userEmail"], FILTER_VALIDATE_EMAIL)) {
          $error_message = "Invalid Email Address";
          }
      }
  
      /* Validation to check if gender is selected */
      if(!isset($error_message)) {
      if(!isset($_POST["gender"])) {
      $error_message = " All Fields are required";
      }
      }
  
      /* Validation to check if Terms and Conditions are accepted */
      if(!isset($error_message)) {
          if(!isset($_POST["terms"])) {
          $error_message = "Accept Terms and Conditions to Register";
          }
      }
  
  
  
  
  
      if(!isset($error_message)) {
          require_once("dbcontroller.php");
          $db_handle = new DBController();
          $query = "INSERT INTO members (username, firstname, lastname, password, email, gender, dob) VALUES
          ('" . $_POST["userName"] . "', '" . $_POST["firstName"] . "', '" . $_POST["lastName"] . "', '" . md5($_POST["password"]) . "', '" . $_POST["userEmail"] . "', '" . $_POST["gender"] . "' , '" . $_POST["dob"] . "' )";
          $result = $db_handle-&gt;insertQuery($query);
          if(!empty($result)) {
              $error_message = "";
              $success_message = "You have registered successfully!";    
              unset($_POST);
          } else {
              $error_message = "Problem in registration. Try Again!";    
          }
      }
  }
  ?&gt;
  &lt;html&gt;
  
  &lt;?php 
  
  
      include 'C:\wamp64\www\Etego\stylesignup.css';
  
  
      ?&gt;
  
  
  &lt;head&gt;
  &lt;title&gt;https://Etego/signup.com&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="frmRegistration" method="post" action=""&gt;
  &lt;table border="0" width="500" align="center" class="demo-table"&gt;
  &lt;?php if(!empty($success_message)) { ?&gt;    
  &lt;div class="success-message"&gt;&lt;?php if(isset($success_message)) echo $success_message; ?&gt;&lt;/div&gt;
  &lt;?php } ?&gt;
  &lt;?php if(!empty($error_message)) { ?&gt;    
  &lt;div class="error-message"&gt;&lt;?php if(isset($error_message)) echo $error_message; ?&gt;&lt;/div&gt;
  &lt;?php } ?&gt;
  &lt;tr&gt;
  &lt;td&gt;User Name&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="demoInputBox allinsc" name="userName" value="&lt;?php if(isset($_POST['userName'])) echo $_POST['userName']; ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;First Name&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="demoInputBox allinsc" name="firstName" value="&lt;?php if(isset($_POST['firstName'])) echo $_POST['firstName']; ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Last Name&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="demoInputBox allinsc" name="lastName" value="&lt;?php if(isset($_POST['lastName'])) echo $_POST['lastName']; ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Password&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" class="demoInputBox allinsc" name="password" value=""&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Confirm Password&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" class="demoInputBox allinsc" name="confirm_password" value=""&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Email&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="demoInputBox allinsc" name="userEmail" value="&lt;?php if(isset($_POST['userEmail'])) echo $_POST['userEmail']; ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
          &lt;tr&gt;
  &lt;td&gt;Date Of birth&lt;/td&gt;
  &lt;td&gt;&lt;input type="date" value="&lt;?php print(date("YYYY-MM-DD"))?&gt;" class="demoInputBox" name="dob" value="&lt;?php if(isset($_POST['dob'])) echo $_POST['dob']; ?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Gender&lt;/td&gt;
  &lt;td&gt;&lt;input type="radio" name="gender" value="Male" &lt;?php if(isset($_POST['gender']) &amp;&amp; $_POST['gender']=="Male") { ?&gt;checked&lt;?php  } ?&gt;&gt; Male
  &lt;input type="radio" name="gender" value="Female" &lt;?php if(isset($_POST['gender']) &amp;&amp; $_POST['gender']=="Female") { ?&gt;checked&lt;?php  } ?&gt;&gt; Female
      &lt;input type="radio" name="gender" value="not specified" &lt;?php if(isset($_POST['gender']) &amp;&amp; $_POST['gender']=="not specified") { ?&gt;checked&lt;?php  } ?&gt;&gt; not specified
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan=2&gt;
  &lt;input type="checkbox" name="terms"&gt; I accept &lt;a href="terms.html"&gt;Terms and Conditions&lt;/a&gt; &lt;input type="submit" name="register-user" value="Register" class="btnRegister"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;div class="header1"&gt;&lt;/div&gt;
      &lt;div class="hdetail1"&gt;&lt;/div&gt;
  
      &lt;h class="etegotxt1"&gt;Etego&lt;/h&gt;
  
      &lt;img src="Etego_Logo.png" alt="Etego logo" width="50" height="50" class="logo1"&gt;
  
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>