3
Error message:
Error: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: This host is not known.
code
$db_name = 'db_name';
$hostname = 'mysql.hostinger.com.br';
$username = 'username';
$password = 'password';
$sql = "INSERT INTO atividade(titulo, descricao, data_atividade) VALUES(:titulo, :descricao, :data_atividade);";
try {
$dbh = new PDO('mysql:host=$hostname;dbname=$db_name', $username, $password);
} catch (PDOException $e) {
echo 'Error: ' . $e->getMessage();
}`
I just left the $hostname
filled out correctly because it’s him who’s making the mistake.
If anyone can help me, I’d appreciate it!
Hostinger in free version does not make connections to mysql database; for this you have to buy a hosting package
– Tiago NET
In the Hostinger Cpanel go to ''Mysql Remote '' and enable the database, simple.
– Oneide Luiz Schneider