Kamil Waniczek
Kamil Waniczek

Reputation: 67

Results are displaying in phpmyadmin and not displaying in the browser

I'm practicing sql and i have excersise in which I have to get Poland population from database and then display every country that have bigger population that Poland. And i have problem. I have tested my query in phpmyadmin and it showed every country that has bigger population than Poland, but when i try to display it in the browser, it shows empty array. Here is my code in which i have sql query and displaying it. Thanks for every answer :)

$sqlToGetPLPopulation = <<<SQL
    SET @population = (
    SELECT 
        `Population` 
    FROM 
        `country`
    WHERE 
        `Code` = 'POL');

    SELECT
        *
    FROM 
        `country` 
    WHERE 
        `country`.`Population` > @population

SQL;

    $result = $conn->query($sqlToGetPLPopulation);
    $data = $result->fetchAll();


    echo "<pre>";
    print_r($data);
    echo "</pre>";

Upvotes: 2

Views: 391

Answers (1)

Christoff X
Christoff X

Reputation: 111

You should probably check that you are connecting to the right SQL server or even maybe the correct database. I've had this many times, and everything works but I don't see the same results. Normally not the DB you think it is...

Upvotes: 1

Related Questions