Error could not find driver in php 7.2



//incluimos nuestra conexion

try {
             //creamos nuestra conexion
             $dbConn = new PDO('mysqli:host=localhost; login_tm', 'root', '1998');

             $dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // creamos el try catch para que nos diga lo que sucede con la conexion 


         require ("../Modelo/conexion_login.php");

          $dbConn->exec("set_character set utf8");

          $sql="SELECT * FROM USUARIOS WHERE CORREO LIKE '%$busqueda'";




    <title>Ver Usuarios Registrados</title>
                <link rel="icon" type="/image/png" href="../../Login/img/tm.ico"/>
                        <link rel="stylesheet" href="" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
                                background-color: yellow;
                                text-align: left;
                                background-color: #0F8886;
                                height: 80px;
                                top: 620px;

                                right: 24px;




               <nav class="navbar navbar-expand-sm bg-info navbar-dark"><!--navbar-expand-lg,md,fixed-bottom-->
                   <a href="#" class="navbar-brand"><img src="ets2_00005.png" style="width: 30px;"></a>
                   <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#uno">
                       <span class="navbar-toggler-icon"></span></button>
                    <div class="collapse navbar-collapse" id="uno"><!-- flex-center, flex-column nav-pills -->
                        <ul class="navbar-nav">
                            <h1>Administracion de usuarios</h1>
                        <li class="nav-item"><a href="../Vista/panel_de_control.php" class="nav-link">Volver al incio</a></li>
                        <li class="nav-item"><a href="#" class="nav-link">Link 2</a></li>
                        <li class="nav-item"><a href="#" class="nav-link">Link 3</a></li>
                        <li class="nav-item"><a href="#" class="nav-link">Link 4</a></li>
                        <li class="nav-item dropdown"><a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" id="navbardrop">Link5</a>
                            <div class="dropdown-menu">
                                <a href="#" class="dropdown-item">Sub item 1</a>
                                <a href="#" class="dropdown-item">Sub item 2</a>
                                <a href="#" class="dropdown-item">Sub item 3</a>
                                <a href="#" class="dropdown-item">Sub item 4</a>
                        <form action="busqueda.php" method="get" class="form-inline">
            <button class="btn-success" type="Submit" name="Buscar">Buscar</button>

    <div class="container">
    <table class="table table-dark table-hover" width='80%' border=0>

    <tr bgcolor='#CCCCCC'>
        <td>Tipo Usuario</td>
                <td>Editar Usuario</td>
                <td>Eliminar Usuario</td>

    while($row = $result->fetch(PDO::FETCH_ASSOC)) {        
        echo "<tr>";
        echo "<td>".$row['correo']."</td>";
        echo "<td>".$row['contrasena']."</td>";
        echo "<td>".$row['tipo_usuario']."</td>";   
        echo "<td><a href=\"../Controlador/editar_usuarios.php?id=$row[id]\">Editar</a</td>";
                 echo "<td><a href=\"../Controlador/eliminar_usuario.php?id=$row[id]\" onClick=\"return confirm('Are you sure you want to delete?')\">Eliminar</a></td>";       

         }catch(PDOException $e) {
             die('Error ' . $e->getMessage());

    <div class="borde3">

               <h1 class="col-12 borde2 fixed-bottom display-4"></h1>  

<script src="" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
        <script src="" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>

asked by Lionardo Gomiz 25.06.2018 в 21:13

1 answer


I tell you that your error is in the following line

$dbConn = new PDO('mysqli:host=localhost; login_tm', 'root', '1998');


Well PDO is an abstraction layer to be able to interact with several database managers, among which, of course, is MySQL; However, when you create the connection, you must point to the MySQL driver and you place mysqli, which, of course, does not recognize because it does not exist.


Declare your same connection string but pointing to mysql

$dbConn = new PDO('mysql:host=localhost; dbname = login_tm', 'root', '1998');

On the other hand it is also necessary that you place dbname = db_name   to indicate to which database you want to access

Here is more information about the official PDO documentation that is for PHP


answered by 25.06.2018 / 21:27