Issue with Connecting Database to My PHP Application

Hi everyone,

I’m facing a bit of a challenge with my PHP application hosted on InfinityFree, and I hope someone here can help me out. I’m trying to connect my PHP script to a MySQL database, but I keep getting an error message that says, “Unable to connect to the database.”

Here’s a bit more detail on what I’ve done so far:

  • I created a MySQL database through the InfinityFree control panel.
  • I double-checked the database name, username, password, and hostname in my PHP code to ensure they match the ones provided in the control panel.
  • I’m using mysqli_connect() to establish the connection.

Despite all this, I still can’t seem to connect. Is there something I’m missing? Could this be related to some server settings or permissions that I haven’t configured correctly?

I’d appreciate any insights or suggestions you all might have. Thanks in advance!

If that does not help share your code and hide your password.

5 Likes

I figured out the issue, and it was a small mistake on my part.:sweat_smile:

It turns out that in my PHP code, I mistakenly typed the database hostname as localhost instead of the actual hostname provided by InfinityFree. Once I corrected the hostname to match the one in my control panel, the connection worked perfectly!

Thank you.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.