title: Error with transaction: beginTransaction() on a non-object
body: <p>I`m working with PDO and prepare statements and now I want to implement transactions, but when I do it I get this error:</p>
  
  <pre><code>Call to a member function beginTransaction() on a non-object in
  </code></pre>
  
  <p>The code is:</p>
  
  <pre><code>include_once '../../includes/db_connect.php';
  include_once '../../includes/psl-config.php';
  $mysqli-&gt;query("SET NAMES 'utf8'");
  date_default_timezone_set('America/Mexico_City');
  $hora = date("d-m-Y g:i a");
  
  $mysqli-&gt;beginTransaction();
  
  //OBTENCIÓN DE LA INFORMACIÓN
  $id = $mysqli-&gt;real_escape_string( $_POST["id"] );
  $fechaEntrada = date("Y-m-d");
  $estatus = "Disponible";
  $idUser = $mysqli-&gt;real_escape_string( $_POST['idUser'] );
  $idUser = $idUser . "  " . $hora;
  
  //SELECIONAR INFORMACIÓN DE LA MAQUINA A ENTRAR
  $sqlMaquina = "SELECT tipo, clave FROM maquinas_orden_renta WHERE id = $id";
  $res = $mysqli-&gt;query($sqlMaquina);
  $rows = $res-&gt;num_rows;
  if (!$res)
      printf("Error message: %s\n", $mysqli-&gt;error);
  $objMaquinaRenta = $res-&gt;fetch_object();
  $tipoMaquina = $objMaquinaRenta-&gt;tipo;
  $idMaquina = $objMaquinaRenta-&gt;clave;
  
  $sql = "UPDATE maquinas_orden_renta SET entradaReal = ?, estatus = ?,updated_by = ? WHERE id = ?";
  $stmt = $mysqli-&gt;prepare($sql);
  if ( false === $stmt )
      die('prepare() failed: ' . htmlspecialchars($mysqli-&gt;error));
  
  $rc = $stmt-&gt;bind_param('sssi', $fechaEntrada, $estatus, $idUser, $id );
  if ( false === $rc )
      die('bind_param() failed: ' . htmlspecialchars($stmt-&gt;error));
  
  $rc = $stmt-&gt;execute();
  
  
  if ( false === $rc )
      die('execute() failed: ' . htmlspecialchars($stmt-&gt;error));
  else{
      if ($tipoMaquina == "conID") {
          $sql2 = "UPDATE maquinas SET estatus = ?, updated_by = ? WHERE IdMaquina = ?";
          $stmt = $mysqli-&gt;prepare($sql2);
          if ( false === $stmt )
              die('prepare2() failed: ' . htmlspecialchars($mysqli-&gt;error));
  
          $rc2 = $stmt-&gt;bind_param('ss', $estatus, $idUser, $idMaquina );
          if ( false === $rc2 )
              die('bind_param2() failed: ' . htmlspecialchars($stmt-&gt;error));
  
          $rc2 = $stmt-&gt;execute();
  
          if ( false === $rc2 )
              die('execute2() failed: ' . htmlspecialchars($stmt-&gt;error));
          else
              echo "Éxito";   
      }
  }
  if (false === $rc AND  false === $rc2) {
      echo "exito";
      $mysqli-&gt;commit();
  }else{
      $mysqli-&gt;rollBack();
      echo "error: $error";
  }
  
  $stmt-&gt;close();
  </code></pre>
  
  <p>So, I don`t know if the function beginTransaction is wrong or something. </p>