Problem when printing data

0

I want to print texts in bootstrap alert mode, but I get the error:

  

Notice: Array to string conversion in   D: \ xampp \ htdocs \ Projects \ ProyectoDriversParadeClub \ DriversParadeClub \ view \ reportses_de_usuarios.view.php   on line 121 Array

I have made a var_dump and the query makes it correct, it is at the time of printing it, I pass the code to you:

<div class="alert alert-info" role="alert">
                <?php
                include_once '../pruebas/conexion.php';
                $sql_leer = 'SELECT * FROM reporteusu WHERE id';

                $gsnet = $pdo->prepare($sql_leer);
                $gsnet->execute();

                $resultado = $gsnet->fetchAll();

                echo $resultado; ?>
            </div>
    
asked by alanfcm 30.07.2018 в 21:23
source

3 answers

0

Inentena asi, in addition to passing the value of the Id you want.

<div class="alert alert-info" role="alert">
    <?php
        include_once '../pruebas/conexion.php';
        $sql_leer = 'SELECT * FROM reporteusu WHERE id= 1';

        $gsnet = $pdo->prepare($sql_leer);
        $gsnet->execute();

        $resultado = $gsnet->fetchAll();
        for ($j=0; $j< $resultado.length ; $j++) {
            echo $resultado[$j]."<br>";
        }
    ?>
</div>

I hope you serve bro ... ReNiceCode ...

    
answered by 30.07.2018 в 21:31
0

You can not say echo $ result because when you tell him to bring you the query data with a fetchAll he brings them in a fix instead of

echo $resultado;

pon

print_r($resultado);
    
answered by 30.07.2018 в 21:54
0

You have a error on this line

$sql_leer = 'SELECT * FROM reporteusu WHERE id';

you have to specify that the id is equal to x nuemro or x string for example

 $sql_leer = 'SELECT * FROM reporteusu WHERE id=5';

are the small mistakes that sometimes make us crazy to walk fast hehe

    
answered by 30.07.2018 в 22:40