<?php $username='andriy'; $login=$_POST["login"]; $password=$_POST["pass"]; echo "$username $login $password<br>"; $connection = new PDO('mysql:host=localhost;dbname=mysite;charset=utf8', 'root', ''); $result=$connection->exec("SELECT * FROM users"); echo "$result"; echo "<br>"; if($result==true) echo"TRUE"; else if ($result==false) echo "FALSE"; ?> 

Tried through mysql the same.

    1 answer 1

    From the documentation

    PDO :: exec () starts the SQL query for execution and returns the number of rows involved in its execution.

    PDO :: exec () does not return the result of a select with a SELECT statement . If you need to select data by this operator once during the execution of the program, use the PDO :: query () method . If you want to run the same query multiple times, it is better to create a prepared PDOStatement request using the PDO :: prepare () method and then run it using the PDOStatement :: execute () method as many times as necessary.