Problem with accessing a FTP site with a PHP script
I created this PHP script (actually it came from my textbook). It apparently connects to the FTP site okay, but I cannot log on. The user name and password have been double-checked for typos, but for security reasons I cannot put them up here, so I just put "host.com", "user_name" and "password" here.
Is there anything I can add to this script that will allow me to see exactly why the user name is not being accepted?
<title>LSR FTP Script</title>
<h1>LSR FTP Script</h1>
// set up variables
$host = 'host.com';
$user = 'user_name';
$password = 'password';
$remotefile = 'addendums.txt.gz';
$localfile = 'addendums.txt.gz';
// connect to host
$conn = ftp_connect("$host");
echo 'Error: Could not connect to ftp server<br />';
echo "Connected to $host.<br />";
// log in to host
$result = ftp_login($conn, $user, $pass);
echo "Error: Could not log on as $user<br />";
echo "Logged in as $user<br />";
echo 'Getting file from server...<br />';
$fp = fopen ($localfile, 'w');
if (!$success = ftp_fget($conn, $fp, $remotefile, FTP_BINARY))
echo 'Error: Could not download file';
echo 'File downloaded successfully';
// close connection to host
Also, if I use my browser to FTP to the FTP site, I CAN enter my user name and password, and can get into the FTP site fine.
The messages I receive when I attempt to connect to the FTP site using my PHP script are as follows:
Connected to idx.fnismls.com..
Error: Could not log on as user_name
Thanks in advance!