How can I handle ftp_login errors to print what I want to screen instead of spitting "warning at line bla bla bla" all over my page if the username or password is incorrect?

// function to connect to FTP server
function connect()
{
global $server, $username, $password;
$conn = ftp_connect($server);
ftp_login($conn, $username, $password);
return $conn;
}

if username or passwd incorrect i get the default:
"Warning: ftp_login cannot login user 'bla bla bla' error line bla bla bla"

    RTFM

    @ftp_login

    the @ sign suppresses errors. If that doesn't work. Use the error_reporting() function to suppress all errors. Since ftp_login returns true / false you can...

    if(!@ftp_login($conn, $username, $password)){
    your_own_error_handling_function();
    }

      Write a Reply...