I receiving this error message and I'm not sure quite why. It works on other servers. The only difference I can see is that PHP is slightly newer than the other servers.
Warning: ftp_login() expects parameter 1 to be resource, boolean given in /usr/local/www/virtual2/66/175/28/117/html/backup/index.php on line 29
<?php
error_reporting(E_ALL);
$ftp_server = 'www.test.com';
$ftp_user_name = 'test';
$ftp_user_pass = 'test';
$to = 'test@yahoo.com';
$subject = 'Aluminum TTS Backup';
$headers = "From: webmaster@test.com\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
"Content-Transfer-Encoding: 8bit\r\n\r\n";
//start ZIP file
$filedate = date("M-j-Y_G:i:s").'.zip';
// set up basic connection start FTP
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
$message1 = "FTP connection has failed!";
exit;
} else {
$message1 = "Connected to ".$ftp_server.", for user ".$ftp_user_name."<p>\r\n";
}
// upload the file
$upload = ftp_put($conn_id, $filedate, $filedate, FTP_BINARY);
// check upload status
if (!$upload) {
$message2 = "".$message1.'FTP upload has failed!';
} else {
$message2 = "".$message1."Uploaded ".$source_file." to ".$ftp_server." as ".$filedate."";
echo $message2;
}
// close the FTP stream
ftp_close($conn_id);
mail($to, $subject, $message2, $headers);
if(file_exists($filedate))
unlink($filedate);
?>