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);
echo " failed db access";
echo " connection failed";
The details have been kept hidden for security reasons.
The above script gives the following output:
Connection success failed db access