Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
Check for logged PHP errors/warnings. –  Michael Hampton Sep 5 '12 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. –  Dude Lebowski Sep 5 '12 at 8:59

1 Answer 1

up vote 0 down vote accepted

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.