@ama123 said:
The $server_name contain the same address that’s shown in the Cpanel
Well, apparently not, or you wouldn’t get that error.
I took a quick look at your code and I see two functions where you use mysql. The first one is configured properly, the second one tries to login as user root on server localhost without any password. The first one should work, the second one won’t.