MySQLi Error 2002 that I don't know how to fix

Hello.
I am hosting a PHP script in http://nerdy.3dp.rf.gd/ that access the SQL database with MySQLi.
With enabled errors, it returns:
Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in /home/vol9_1/rf.gd/rfgd_19447245/nerdy.3dp.rf.gd/htdocs/index.php on line 40.

After some extensive search on Stackoverflow, all errors just seemed to point that the socket it was connected to was wrong or that the connecting ports were incorrect. I honestly don’t know what’s causing this problem, and I couldn’t find any solution for it. Any help is appreciated.

Thanks in advance.

Do you still experience this problem? It could be a minor outage on the database server if it has been resolved already.

Yes, I still have that problem, not fixed

I checked the status of your database server with a test script, but I didn’t get any errors like that. Please make sure you are using the correct MySQL hostname.

I am using the correct hostname according to CPanel and PHPMyAdmin, that can connect to the database and use the tables. However my script can’t

@fpuede said:
I am using the correct hostname according to CPanel and PHPMyAdmin, that can connect to the database and use the tables. However my script can’t

I’m pretty certain it’s a script issue, since I was able to connect with a script of my own. I also checked your script, but I wasn’t able to produce any output with it so I couldn’t really check why it wasn’t working.

There is a parameter you can pass to the script that generates the error, as it executes the functions to read the config file, connect and use the table. Pass ?echo=1 and it should display it.

@fpuede said:
There is a parameter you can pass to the script that generates the error, as it executes the functions to read the config file, connect and use the table. Pass ?echo=1 and it should display it.

Thanks, I was able to recheck your script.

And it turns out it is a script issue. You’re using mysqli_connect in a function, but the connection details are not available in the function scope. $sql_host is NULL there.