Page 1 of 1

ftp_connect problems

Posted: Thu Oct 20, 2005 11:56 am
by gtm
I am trying to connect to an ftp server with the following code:

Code: Select all

<?php

// set up basic connection
$ftp_server = "ftp.atmos.washington.edu";
$conn_id = ftp_connect($ftp_server);

// check connection
if (!$conn_id) {
	
	echo "No connection made!";	
   } 
   else {
   	$login_result = ftp_login($conn_id, "anonymous", "gtm");
	if ((!$login_result)) {
       echo "<P>FTP connection has failed!";
       echo "<P>Attempted to connect to $ftp_server";
       exit;
	   }
	 else  
       echo "<P>Connected to $ftp_server, for user $ftp_user_name";
   }

ftp_close($conn_id);

?>
However, the ftp_connect command appears to be returning FALSE indicating an error since I hit my error message "No connection made".


What I can not figure out is that I can connect without any problem using ftp from a command prompt, a browser or ws_ftp. I am sure the port is 21 since I can see the port when I connect through ws_ftp. The only difference I can think of is that I am running the php code on a server at my ISP and I am using the ftp commands from my own computer.

Any suggestions?

Thanks

George