Thanks again for the help. Indeed, I should have written “database host name” and not “database name”.
Following your suggestion, I tried replacing the host name with its IP address. Once again, I can access the database from Dreamhost, but not from my other web host (by using the same script).
MyphpAdmin doesn’t report any (additional) processes when I am trying to connect from my other web host. I even modified the script with “sleep(10);” before closing the mysql connection so as to give me some time to see if anything happens, and while the connection from Dreamhost shows up, there is absolutely no sign of anything when the script it run from my other web host.
I then installed XAMPP to give me an apache server and mysql on my computer. It confirms that there is no problem with Dreamhost: I can run the php code from my temporary server to succesfully connect to the database. I also managed to set up a database on the home computer server and temporarily opened the firewall. Results: I can connect to it with the script from Dreamhost and from my computer, but not from my other web host.
This all definitely points towards my other web host. However, I sent them an email and they replied by saying that accessing remote databases is not prevented in any way and should work.
For what it is worth, if I try to connect to a remote host that does not exist (in this case “kaak.kop”), I get:
Could not connect: Unknown MySQL Server Host ‘kaak.kop’ (1)
rather than the typical
Could not connect: Lost connection to MySQL server during query
So at least it tries connecting, or something. It would just be interesting to know why the connection doesn’t work.
To tell the truth, I am actually not really sure if I should believe my other web host when they say that the connection is not prevented. Last summer I tried to get URL frame forwarding to work within their system, but as I had trouble figuring out their control panel, I asked them about it. Their response was “sure, you can make pages with frames”. I wrote back as kindly as I could telling them that I am not really interested in making pages with frames, but doing frame forwarding. They replied by sending me instructions on how to code pages with frames. This went on about half a dozen rounds until I asked them if they actually know what I am talking about, at which point they got annoyed, sent me one last spicy email and never continued the thread any further. About a month later, they silently disabled the “frame forwarding” option from their control panel.
Well, they are cheap and are very rarely down. And maybe I just got someone who was in the support as a summer replacement, but still…
In any case, thank you for your help. I think I will just give up on trying to connect to Dreamhost from my other web host (unless you have any more ideas) and try to find another solution to what I am attempting to achieve.