Home Executing SELECT query return false
Reply: 0

Executing SELECT query return false

user1216
1#
user1216 Published in July 22, 2018, 8:03 pm

I have a PHP site that I uploaded in 000webhost. It needs a database to store data. But when I try to sign in it didn't sign in. When I check the connection it turns out the connection was fine. Still not able to access the database. So I wrote a small script to check database access and it failed. I have a table named songs which contains some songs.

Here is the script :

<?php
    ob_start();

    session_start();
    $host = 'localhost';
    $user = 'xxxxxxx';
    $pass = 'xxxxxxx';
    $db = 'xxxxxxx';

    $timezone = date_default_timezone_set("Asia/Kolkata");

    $con = new PDO("mysql:host=$host;dbname=$db", $user, $pass); 

    if($con)
    {
        echo "Connection success";
        $query  = mysqli_query($con, "SELECT * FROM songs");
        if($query){
            $tb = mysqli_fetch_array($query);
            print_r($tb);
        }
        else {
            echo " failed db access";
        }
    }   
    else {
        echo " connection failed";
    }    
?>

The details have been kept hidden for security reasons. The above script gives the following output:

Connection success failed db access
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.3205 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO