Hai there, I can’t connect to my database using this code:
<?php $servername = "localhost"; $username = "id2379720_jhapz"; $password = "*******"; try { $conn = new PDO("mysql:host=$servername;dbname=id2379720_db_test", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>Please be careful when posting this kind of code, as it contained your database password.
Try this:-
Hi @jhapz!
This means your database credentials are incorrect. Please make sure they are the same as the ones from 000webhost cPanel > Manage databases.
If you have forgotten your DB password please go to 000webhost cPanel > Manage databases > locate DB > Manage > Password and try to connect again with the new password.
i changed the database password to numerical only and its was solved. but i still not understand about this error