As you can see in this topic, the “No such file or directory” error means you are using localhost as the database hostname, instead of the actual value. This is also the default value you may see if you don’t provide any MySQL hostname to the connection.
Can you please debug the code to check that all the $sql_db_??? variables are filled correctly? Your code sets them all to an empty string, but looking at the code they may be defined elsewhere. Please check and make sure that’s actually the case.