Please test this code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gtm
Forum Newbie
Posts: 6
Joined: Sun Oct 16, 2005 10:22 am

Please test this code

Post by gtm »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I am having trouble understanding why the following code will not connect to the ftp site in the code. Other sites work fine so I think the code is OK. On the other hand I can connect to ftp.atmos.washington.edu through a command prompt or ws_ftp. Any suggestions?

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);

?>

Thanks

George


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Works for me.

Do you go to UDUB?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Are you sure that php is compiled --enable-ftp switch?

Code: Select all

<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);

if (!extension_loaded('ftp'))
{
  echo "Tell the sysadmin to recompile php with --enable-ftp";
}
?>
gtm
Forum Newbie
Posts: 6
Joined: Sun Oct 16, 2005 10:22 am

Post by gtm »

Thanks for testing the code. It works for me as well as long I am not trying to connect to this particular server. Could there be some conflict with my ISP and this server?

I do not go to UDUB but just want to access some of thier weather data.

George
Post Reply