Hi guys,
I've stumbled upon a weird one!
I try connecting to my server with ftp_connect using this next bit of code:
$conn_id = ftp_connect("www.mydomain.com");
echo $conn_id."<br>";
$login_result = ftp_login($conn_id, 'user', 'pass');
echo $login_result."<br>";
$contents = ftp_nlist($conn_id, "htdocs");
var_dump($contents);
ftp_close($conn_id);
When I run this from my own testserver it all works nicely, it connects to the remote mydomain.com and echoes the result id#, echoes a 1 (for true) and echoes an array.
Now when I upload this exact script to mydomain.com all it echoes is NULL.
So form an external server it works but from the mydomain server itself it doesn't.
Looking at the phpinfo() it says that FTP is enabled and that FTP is a registered stream. That explains I'm not getting a 'call to undefined function' which you normally would expect when FTP doesn't work for PHP.
I've tried using the server's IP instead of domainname and I tried 127.0.0.1 both to no avail.
The configure command var in phpinfo() says:
'./configure' '--enable-calendar' '--enable-dba' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-mbstring' '--enable-memory-limit' '--enable-sockets' '--enable-xslt' '--enable-zend-multibyte' '--with-bz2' '--with-curl' '--with-db4' '--with-dom-exslt=/usr/local/lib' '--with-dom-xslt=/usr/local/lib' '--with-dom=/usr/local/lib' '--with-expat-dir=/usr/local' '--with-flatfile' '--with-freetype-dir=/usr/local/lib' '--with-fribidi=/usr/local' '--with-gd' '--with-gdbm' '--with-gettext' '--with-gnu-ld' '--with-iconv=/usr/local' '--with-imap' '--with-imap-ssl' '--with-inifile' '--with-jpeg-dir=/usr/local/lib' '--with-ldap=/usr/local' '--with-mcrypt' '--with-mhash' '--with-ming' '--with-mysql=/usr/local' '--with-ndbm' '--with-openssl' '--with-pcre-regex' '--with-pgsql=/usr/local' '--with-png-dir=/usr/local/lib' '--with-snmp' '--with-t1lib=/usr/local/lib' '--with-tiff-dir=/usr/local/lib' '--with-ttf' '--with-xml' '--with-xslt-sablot=/usr/local/lib' '--with-zip=/usr/local/lib' '--with-zlib' '--enable-cgi' '--disable-cli' '--enable-fastcgi' '--enable-force-cgi-redirect'
Now I do believe I'm doing everthing right. But it just won't work.
I believe this one is for the experts!?!?
Please help!
Cheers
PS. I just changed mydomain.com and the user and pass to that of my testserver, and calling the script from mydomain.com,
$conn_id = ftp_connect("www.testserver.com");
echo $conn_id."<br>";
$login_result = ftp_login($conn_id, 'testuser', 'testpass');
echo $login_result."<br>";
$contents = ftp_nlist($conn_id, "www");
var_dump($contents);
ftp_close($conn_id);
and guess what, it all works nicely. So it works to and from external servers but to to itsself?? It must be some kind of server setting, problem being I need to know exactly what it is so I can slap this REALLY crappy host XS4all.nl with it!