How can I connect to a db4free.net database with PHP?
database, php
Solution
This worked for me...
$host = "db4free.net";
Problem
I made a db on db4free.net, and I want to connect to it with php: ``` $username = myusername; $password = mypw; $host = "db4free.net:3306"; $dbname = mydbname; $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'); try { $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options); } catch(PDOException $ex) { die("Failed to connect to the database: " . $ex->getMessage()); } ``` And I get this error message: Failed to connect to the database: SQLSTATE[HY000] [2005] Unknown MySQL server host So I was thinking , that the hostname is wrong, so i tried to varie it a bit (adding /dbname or /username or removing the port, ect.). I've tried all the combinations, but none of them worked. The login data are checked multiple times. What could be the problem?