Home Executing SELECT query return false
Reply: 0

Executing SELECT query return false

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 :


    $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); 

        echo "Connection success";
        $query  = mysqli_query($con, "SELECT * FROM songs");
            $tb = mysqli_fetch_array($query);
        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