473,412 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

How to fix connection not established error for FTP connection code?

omerbutt
638 512MB
hi everyone,
i am having a problem while connecting to a particular server where i have to transfer the files the code works everywhere else but with this ftp it gives me warning as follows,
Warning: ftp_login() expects parameter 1 to be resource, boolean given in D:\xam
pp\htdocs\ews\projects\whatever-tiff\vanguard\stage\batch-upload.php on line 26
FTP connection not established!
One thing that when i tried to connect it VIA CUTEFTP it did not connected until i specified the
PROTOCOL TYPE =FTP WITH TLS/SSL (PORT 990 - Implicit)

here is the code that is working perfectly
Expand|Select|Wrap|Line Numbers
  1. include("includes/config-batch.php");
  2. include("includes/ftp.trans.php");
  3. $myFtp=new Ftp();
  4.  
  5. /*BATCH UPLOAD PROCESS*/
  6.  
  7. // --------------------------------------------------------------------
  8. // THE TRIGGER
  9. // --------------------------------------------------------------------
  10.  
  11.   // set the various variables
  12.    $myFtp->ftproot    =    "/Folder1/Sub-folder/hbw/";
  13.    $myFtp->srcroot    =    "D:/xampp/htdocs/ews/projects/whatever-tiff/";
  14.  
  15.    // connect to the destination FTP & enter appropriate directories both locally and remotely
  16.    $myFtp->ftpc = ftp_connect("sslftp.nyc.gov");
  17.    $myFtp->ftpr = ftp_login($myFtp->ftpc,"user","pass");
  18.  
  19.     if((!$myFtp->ftpc) || (!$myFtp->ftpr)) { 
  20.         echo "FTP connection not established!\r\n"; die(); 
  21.     }else{echo "FTP connection established!\r\n";}
  22.       if (!chdir($myFtp->srcroot)) { 
  23.         echo "Could not enter local source root directory.\r\n"; die(); 
  24.     }else{echo "Entered local source root directory!\r\n";}
  25.        if(!ftp_chdir($myFtp->ftpc,$myFtp->ftproot)) { 
  26.         echo "Could not enter FTP root directory.\r\n"; die(); 
  27.     }else{echo "Entered FTP root directory!\r\n";}
  28.      return;
  29.    // start ftp'ing over the directory recursively
  30.    $res=$myFtp->getBatchFiles($conn);
  31.     echo $res."\r\n";
  32.    if($res){
  33.            echo "All File(s)transffered\r\n";
  34.    }else{
  35.            //echo "The File(s) could not be transferred to the remote location \r";
  36.         echo "There are no File(s) to be transferred to the remote location \r\n";
  37.    }
  38.  
  39.    // close the FTP connection
  40.    ftp_close($myFtp->ftpc);
  41.    echo "Operation Completed.....Exiting Now\r\n";
  42.  
Dec 9 '10 #1
5 3381
code green
1,726 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. $myFtp->ftpc = ftp_connect("sslftp.nyc.gov");
must be returning false
Dec 9 '10 #2
omerbutt
638 512MB
Yes it is returning False, what could it be ....something to do with the hosting end ..??..although it is connected via CUTEFTP...i even tried specifying the port num also
like 21,22,24,990 ,but it is always returning false.
regards,
Omer Aslam.
Dec 13 '10 #3
code green
1,726 Expert 1GB
21,22,24,990
This is not the port number it is the ip address.
Should be '.' not ',' and needs to be in quotes also
Expand|Select|Wrap|Line Numbers
  1. ftp_connect('21.22.24.990')
Test port with
Expand|Select|Wrap|Line Numbers
  1. fopen('ftp://21.22.24.990') or http://... 
Is the port number definitely 21?
Dec 13 '10 #4
omerbutt
638 512MB
lol no Green i was trying to tell that i have tried different combinations of the port for the port parameter in ftp_connect like the following
Expand|Select|Wrap|Line Numbers
  1. $myFtp->ftpc = ftp_connect("sslftp.nyc.gov",21);
  2.  
  3. $myFtp->ftpc = ftp_connect("sslftp.nyc.gov",22);
  4.  
  5. $myFtp->ftpc = ftp_connect("sslftp.nyc.gov",24);
  6.  
  7. $myFtp->ftpc = ftp_connect("sslftp.nyc.gov",990);
  8.  
  9.  
i surely am not that MoNkEy to do such a mistake Green :D , but may be the typo made you think like that , hope you get what i was trying to tell ...i havenot tried to specify the port number before , as it embeds the 21 as the parameter for port number automatically if not specified
regards,
Omer Aslam
Dec 14 '10 #5
code green
1,726 Expert 1GB
I have found using DNS to be unreliable with ftp_connect().
So persevere using 21.22.24.990.
Test this with cuteFTP. Is it correct?
I have never needed to define port 21.
Dec 15 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on...
2
by: Ramir Santos | last post by:
my analysis server is hosted on a win2k server with IIS, the hosting page is on another machine. I have followed everything as per MS KB article and I could not connect through the analysis server...
4
by: TP | last post by:
Hi, This is probably my 7th post of the day. not spamming, just want to get the questions out, so that I can find the answers and post them back or some good soul can help me out. Right now I...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
3
by: Jeremy Dillinger | last post by:
I am trying to design a program that will use data from a MySQL database. Currently all the data is being used with PHP scripts from a website. I am also trying to build a software solution that...
0
by: NewsReader | last post by:
Hello, I have been looking around the net for a script to help me connect to and help gather information from Cisco routers/switches. I have pieced together a couple of different scripts from...
0
by: cj.snead | last post by:
Hello, I am having trouble connecting to a remote named instance of SQL Server via Pocket PC. I have had absolutely no luck connecting with VS 2005 (even to a default instance), so I wen't back...
0
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've my win32 application which connecting to my sql database. till now i used MSDE as my database and now i want to upgrade to sql express 2005. after the upgrade i tried to connect to the...
10
by: mairhtin o'feannag | last post by:
Hello, I'm having problems connecting to my new v9 db box. The pertinent information is below: DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.