I tried to write a PHP script for my jobs ftp but I keep getting this error.
Connecting to 64.118.238.214 via FTP
Connected...
Warning: ftp_nlist(): php_connect_nonb() failed: No route to host (113) in /home/alien0us/public_html/static/ftp_ez.p hp on line 38
Warning: Invalid argument supplied for foreach() in /home/alien0us/public_html/static/ftp_ez.p hp on line.
here is the source below:
// some variables
$host = "hostsIP";
$un = "def_username";
$pw = "def_password";
echo "Connecting to " . $host . " via FTP
";
// connection code block
$ftp_conn = ftp_connect($host) or die("Could not connect to FTP server");
$ftp_login = ftp_login($ftp_conn, $un, $pw) or die("Unable to login");
// end connection code block
// enable passive mode
$mode = ftp_pasv($ftp_conn, TRUE);
// end enable passive mode
// check login & connection
if((!$ftp_conn) || (!$ftp_login) || (!$mode)) {
echo "FTP connection failed.
";
}
else {
echo "Connected...
";
}
// end login & connection check
// run nlist to list directory contents
$dir_list = ftp_nlist($ftp_conn, "");
foreach ($dir_list as $list) {
echo "
$list";
}
//close
ftp_close($ftp_conn);
// end <-
?>
any help?
Connecting to 64.118.238.214 via FTP
Connected...
Warning: ftp_nlist(): php_connect_nonb() failed: No route to host (113) in /home/alien0us/public_html/static/ftp_ez.p
Warning: Invalid argument supplied for foreach() in /home/alien0us/public_html/static/ftp_ez.p
here is the source below:
// some variables
$host = "hostsIP";
$un = "def_username";
$pw = "def_password";
echo "Connecting to " . $host . " via FTP
";
// connection code block
$ftp_conn = ftp_connect($host) or die("Could not connect to FTP server");
$ftp_login = ftp_login($ftp_conn, $un, $pw) or die("Unable to login");
// end connection code block
// enable passive mode
$mode = ftp_pasv($ftp_conn, TRUE);
// end enable passive mode
// check login & connection
if((!$ftp_conn) || (!$ftp_login) || (!$mode)) {
echo "FTP connection failed.
";
}
else {
echo "Connected...
";
}
// end login & connection check
// run nlist to list directory contents
$dir_list = ftp_nlist($ftp_conn, "");
foreach ($dir_list as $list) {
echo "
$list";
}
//close
ftp_close($ftp_conn);
// end <-
?>
any help?
