rhyspaterson Posted May 25, 2007 Share Posted May 25, 2007 Hey guys, Running a really simple script here $FTPserver = "xxx.xxx.xxx.xxx"; $FTPuser ="xxxxxxx"; $FTPpass ="xxxxxxx"; $ftp = ftp_connect($FTPserver) or die ("Can't connect to FTP Server : $FTPserver"); $login = ftp_login($ftp, $FTPuser, $FTPpass) or die ("Can't login to FTP Server : $FTPServer"); I get the first error (can't connect). However when i connect through a browser (ftp://xxx.xxx.xxx.xxx) it works fine. Obviously im missing something fundamental here. Can anyone point me in the right direction? Cheers, /Rhys Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/ Share on other sites More sharing options...
trq Posted May 25, 2007 Share Posted May 25, 2007 Maybe your host is blocking the ftp port. Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261222 Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 try $ftp = ftp_connect($FTPserver, 21, 90) or die ("Can't connect to FTP Server : $FTPserver"); if this fails contact the host to check Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261223 Share on other sites More sharing options...
rhyspaterson Posted May 25, 2007 Author Share Posted May 25, 2007 Thanks for your quick replies. Tried the above code suggested however the connection still failed. The Linux box is sitting next to me so contacting the host is not really an issue (the host being me, haha). The FTP port is allowing connections. Hmm, confused i am. Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261226 Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 have you tried ip 127.0.0.1? no idea if it will work but worth a shot or the external IP, Remember it could be the router blocking it.. you could ask for a friend to FTP in via IE using the external IP Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261229 Share on other sites More sharing options...
trq Posted May 25, 2007 Share Posted May 25, 2007 The FTP port is allowing connections. If thats the case, I just don't see any other issues. Do you have error_reporting enabled and set to display errors? Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261230 Share on other sites More sharing options...
rhyspaterson Posted May 25, 2007 Author Share Posted May 25, 2007 Yeah i will try it. Just to clarify, it is a separate box i am trying to FTP to. But i think the external IP sounds like a shot. Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261231 Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 External box yes but is the PHP also running on that box ? if so its local to the code itself! Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261232 Share on other sites More sharing options...
trq Posted May 25, 2007 Share Posted May 25, 2007 have you tried ip 127.0.0.1? no idea if it will work but worth a shot Unless your running an ftp server on the same machine as the web server that wont connect either. Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261233 Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 I know i kinda assumed he did (plus add that in the last post) Unless your running an ftp server on the same machine as the web server that wont connect either. Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261235 Share on other sites More sharing options...
rhyspaterson Posted May 25, 2007 Author Share Posted May 25, 2007 Hey guys, Sorry the PHP was running on my box and connecting to a separate box. I found the problem however. FTP was denying connections that were not local. The box i was running the PHP FTP connection off was located off site somewhere. Was a simple process of changing the hosts file to accept FTP connections from the IP address. Thanks so much for your help guys. Whoever mentioned the external IP put me on the right path. Cheers, /Rhys edit: looking for the 'solved' button but cant find it Quote Link to comment https://forums.phpfreaks.com/topic/52895-solved-basic-ftp-issues/#findComment-261245 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.