I am trying to connect to multilple ftp servers using ftp_connect
and ftp_login
. My code is very simple as given
foreach ($ftp_accounts as $ftp_account) {
$connect_id = $ftp_account['server'];
$user = $ftp_account['user'];
$pass = $ftp_account['password'];
echo 'Ftp Server: '.$connect_id.'<br> Username: '.$user. '<br> Password: '.$pass.'<br>';
if (ftp_login($connect_id, $user, $pass)){
echo "| Connected to server " . $connect_id . " as " . $user . '<br>';
} else {
echo "Couldn't connect to $connect_id as $user
";
}
}
I have a table in my database with multiple servers and their credentials. but the code i wrote give me the following error (warning) message
ftp_login() expects parameter 1 to be resource, string given
and it goes to the else statement for every server.
Any idea what I am doing wrong ?
Thanks in advance