Accessing external database: ERR_INCOMPLETE_CHUNKED_ENCODING

I found the solution by logging into the site FTP, renaming my WP site’s index.php to index.php_, and supplying this code in a new index.php file:

<!DOCTYPE html>
<html>
<body>

<?php
$servername = "xxx.xxx.xxx.xxx";
$username = "xxxxx";
$password = "xxxxx";

try {
    $conn = new PDO("mysql:host=$servername;dbname=xxxxxx", $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();
    }
?>

</body>
</html>

This gave a far more meaningful error message, saying that access was denied for my user. So I entered phpmyadmin, and ran a query to find the host name, and then called nslookup in a terminal with that host name as argument. And lo and behold, the web hosting had changed the database server IP address (I had tried to work with just the hostname, but this being a shared hosting and me using a temporary URL seems to botch that way of doing it).

So I fixed the IP address and I finally could connect and populate my forms in WordPress using the database.