I've recently started getting some errors when trying to run php scripts that was suposed to open/read external .txt files.
I also can't open FTP connections with php codes, because it just returns that the connection couldn't be made.
Examples of things that I'm trying out:
// This gives me a "failed to open stream: No such file or directory" even though, if I just copy that address in a web browser, it opens up fine!
$array = file("www.domainName.com/folder1/folder2/test.txt");
// This one timeout after a while.
$array = file("http://www.domainName.com/folder1/folder2/test.txt");
The script that I'm trying to run is vital to our business, so I did the following as a workaround:
// It Works! (note that I had to go one level below, since the script is in another folder)
$array = file_get_contents('../folder1/folder2/test.txt');
So, it seems like the problem is something with the php script not being able to resolve the "www" address? In the case of the .txt file (that is hosted inside the same server) it is pretty much ok, since I could open via manual pathing.
But that also happens when I try to open a FTP address (that is hosted in the same server):
// This doesn't work, it can't establish a connection
// "ftp_login() expects parameter 1 to be resource, boolean given" is returned
$conn_id = ftp_connect("ftp.domainName.com");
$login_result = ftp_login($conn_id, "user", "pass");
The thing is that I need to open a ftp connection in the php script, because the files that I need to use is in another user (the .php scripts are in UserA, while the files that I need to manipulate is in UserB). Again, the FTP connection works fine when I try opening it with a web browser, or a FTP Client, using the same credentials that I gave in the code...
What confuses me even more, is that these scripts that I'm trying to run was working fine for a whole 2 years or so, and suddenly, it stopped working! (more specifically, since the last week). I should also note, that there hasn't been any major (or minor) update in the server (in fact, it literally stopped working for no reason).
Sorry for the long post, I wanted to make sure that I didn't miss anything.