I am trying to connect FTP Server ushin php code, if i put FTP-Servaer Name Invalid then its end the script and not return false in $conn_id.
code spinet:
$conn_id = ftp_connect($_POST['ftp_server']);
if($conn_id)
{
echo "invalid server name";
}
else
{
if(ftp_login($conn_id, $_POST['ftp_username'], $_POST['ftp_password']))
{
$connection_status = 'tested';
echo "<script>alert('Correct FTP login credentials');</script>";
}
}
its stop script at first line and not shows echo "invalid server name";
error
ftp_connect() [function.ftp-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known.
i need to alert user if he puts invalid server-name. Thanks !!!
I think you should just need to change
if($conn_id)
toif($conn_id === FALSE)
EDIT
Try running this:
You should get this:
try this and you done
Cheers !!!