我正在制作的备份脚本出现了一些问题,它输出了一些错误。此脚本的目的是备份mysql文件,将其保存到本地服务器,但也将其上载到远程服务器。谢谢
警告: ftp_login() Function.ftp登录:登录身份验证失败.第123项
警告: ftp_chdir() function.ftp-chdir:您没有登录.第125行
警告: ftp_fput() function.ftp-fput:您没有登录.第127行
//***********SAVE FILE***********
$handle = fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+'); //db-backup-time-md5hash.sql ( opens for reading and writing )
fwrite($handle,$content); //copy content over to open file
fclose($handle); //close the file
// open some file for reading
$file = 'db-backup-1322909178-07f410c05ec2f736364667e1febd105f.sql';
$fp = fopen($file, 'r');
$ftp_server = "REMOTE SERVER";
$ftp_user_name = "REMOTE USER";
$ftp_user_password = "REMOTE PASS";
$rempath = "/public_html/";
// set up basic connection
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_chdir($conn_id, $rempath);
// try to upload $file
if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
echo "Successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);发布于 2011-12-03 11:27:58
这一行有一个错误:-
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);$ftp_user_pass在您的脚本中没有定义:-
$ftp_user_password <-- what was defined
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);如果这有帮助的话,确保你的头不要撞到墙上
https://stackoverflow.com/questions/8367298
复制相似问题