0

I try to use the php ftp_connect fucntion on my dedicated server and I'm unable to establish a connection:

$conn_id = ftp_connect($ftp_server, 21) or die("Unable to connect to $ftp_server") ;

I'm sure the function is available as I test with :

function_exists('ftp_connect')

and it returns true

When I ftp the server through the shell I can reach it so I guess it's not a firewall issue. Am I missing something else ?

Thanks for your precious advices

2
  • Check for logged PHP errors/warnings. Sep 5, 2012 at 8:48
  • I've checked and nothing. The function return false. I don't understand as the same code on my local machine works like a charm. Sep 5, 2012 at 8:59

1 Answer 1

0

PHP will log a warning if ftp_connect fails. However, you may have logging disabled or going to an unexpected place. Check your php.ini and related configuration files to ensure that logging is enabled and to specify where the logs are written.

To diagnose this problem without access to logs, try running PHP from the command line. For instance:

$ php
<?php $x = ftp_connect("nowhere.com");

Ctrl+D

PHP Warning:  ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .