benedictbutlin
Technical User
I'm trying to connect to an ftp sever but getting the following error...
From what i've googled, it could be a setting that needs to be configured in the php.ini? if this is so, and based on my error can you advise what i'm meant to change, or maybe the code can be made to work without php.ini changes? here's my code....
Warning: ftp_connect() [function.ftp-connect]: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /directory/file.php on line 12
Warning: ftp_login() expects parameter 1 to be resource, boolean given in /directory/file.php on line 13
Warning: ftp_connect() [function.ftp-connect]: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /directory/file.php on line 16
Couldn't connect to ftp://ftp2.xxxx.com
From what i've googled, it could be a setting that needs to be configured in the php.ini? if this is so, and based on my error can you advise what i'm meant to change, or maybe the code can be made to work without php.ini changes? here's my code....
Code:
$ftp_server = "ftp://ftp2.xxxx.com";
$ftp_user = "xxxx";
$ftp_pass = "xxxx";
$ftp_connect = ftp_connect($ftp_server);
$ftp_loggedIn = ftp_login($ftp_connect, $username, $password);
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
$loggedIn = ftp_login($ftp_connect, $ftp_user, $ftp_pass);
if (true === $ftp_loggedIn) {
echo 'Success!';
} else {
throw new Exception('Unable to log in');
}