I uploaded my website with a free account on 000webhost and I'm using their server. The problem is that when I try this it says: 'Not connected to server'.
<?php
$servername = "localhost";
$username = ".....";
$password = ".....";
$database = "id7644931_test";
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
if(!$con){
echo 'Not Connected To Server';
}
When I try this on my computer and with my database it works fine and it has no problems connecting to the server. Has anyone any experience with 000webhost and their databases?
localhost
. It's pretty standard on shared hosting for the database to be on a different server. Consult your host for connection details. Barring that, use php.net/manual/en/pdo.errorinfo.php to get details of the error. – ceejayoz Oct 29 '18 at 1:26