title: PHP Fatal error: Call to a member function prepare() on a non-object in PDO and mysqli
body: <p>I have tried several ways to use parameterized statements but I still keep having issues.</p>
  
  <p>At first I tried parameterized statements:</p>
  
  <pre><code>$dbc = new PDO("mysql:host=localhost;dbname=the_name", 'the_login', 'the_pass');
  $query = $dbc-&gt;prepare('INSERT INTO req_form (lname, fname, email, address, city, state, zip, phone, affiliation, role, ip_address, abc, ace, carr, ema, tuac, olatc_temp) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
  $query-&gt;execute(array($lname, $fname, $email, $addr, $city, $state, $zip, $phone, $affiliation, $prof_role, $_SERVER['REMOTE_ADDR'], enum($abc), enum($ace), enum($carr), enum($ema), enum($tuac), enum($last)));
  </code></pre>
  
  <p>but got "PHP Fatal error: Call to a member function prepare() on a non-object"</p>
  
  <p>Now I've tried:</p>
  
  <pre><code>$conn = new mysqli('localhost', 'the_login', 'the_password', 'the_name');
  $sql = 'INSERT INTO req_form (lname, fname, email, address, city, state, zip, phone, affiliation, role, ip_address, abc, ace, carr, ema, tuac, olatc_temp) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
  $query = $conn-&gt;prepare($sql);
  $query-&gt;bind_param('ssssssissssssssss', $lname, $fname, $email, $addr, $city, $state, $zip, $phone, $affiliation, $prof_role, $_SERVER['REMOTE_ADDR'], enum($abc), enum($ace), enum($carr), enum($ema), enum($tuac), enum($last));
  $query-&gt;execute();
  </code></pre>
  
  <p>I still get the error, am I possibly using a reserve name in my insert statement?</p>
  
  <p>EDIT (added the enum function):</p>
  
  <pre><code>function enum($ar){
      if(count($ar)&gt;1)
          return 'BOTH';
      else
          return $ar;
  }
  </code></pre>
  
  <p>EDIT (output of mysqli section of phpinfo():</p>
  
  <pre><code>mysqli
  MysqlI Support enabled 
  Client API library version  mysqlnd 5.0.8-dev - 20102224 - $Id: SOME_VALUE_WAS_HERE $  
  Active Persistent Links  0  
  Inactive Persistent Links  0  
  Active Links  0  
  
  Directive Local Value Master Value 
  mysqli.allow_local_infile On On 
  mysqli.allow_persistent On On 
  mysqli.default_host no value no value 
  mysqli.default_port 3306 3306 
  mysqli.default_pw no value no value 
  mysqli.default_socket no value no value 
  mysqli.default_user no value no value 
  mysqli.max_links Unlimited Unlimited 
  mysqli.max_persistent Unlimited Unlimited 
  mysqli.reconnect Off Off 
  </code></pre>
  
  <p>When I put var_dump($conn) right after  the first line it prints stuff out, if I put it right above the $conn->prepare it displays NULL</p>