Danny620 Posted November 8, 2012 Share Posted November 8, 2012 My Code // *** Set up basic connection $this->connectionId = ftp_connect($server); // *** Login with username and password $loginResult = ftp_login($this->connectionId, $ftpUser, $ftpPassword); // *** Sets passive mode on/off (default off) ftp_pasv($this->connectionId, $isPassive); // *** Check connection if ((!$this->connectionId) || (!$loginResult)) { $this->logMessage('FTP connection has failed!'); $this->logMessage('Attempted to connect to ' . $server . ' for user ' . $ftpUser, true); return false; } else { $this->logMessage('Connected to ' . $server . ', for user ' . $ftpUser); $this->loginOk = true; return true; } } When i run it i get: Warning: ftp_login() [function.ftp-login]: Login failed. Please verify the username and password supplied, and that FTP has been unlocked. Check your control panel or contact support for more information. in /Applications/XAMPP/xamppfiles/htdocs/ftp_class.php on line 31 Array ( [0] => Attempted to connect to ftp.socialnewsoffice.co.uk for user socialnewsoffice.co.uk ) how can i catch the warning message? Quote Link to comment https://forums.phpfreaks.com/topic/270450-ftp_login-login-error-php/ Share on other sites More sharing options...
MMDE Posted November 8, 2012 Share Posted November 8, 2012 (edited) What exactly do you want? Do you want to catch it so the user doesn't see it and you can write your own error? Read the manual: http://php.net/manua...n.ftp-login.php bool ftp_login ( resource $ftp_stream , string $username , string $password Return Values Returns TRUE on success or FALSE on failure. If login fails, PHP will also throw a warning. How to suppress error and warning in PHP: http://php.net/manua...rrorcontrol.php $logged_in = @ftp_login($ftp_stream, $username, $password); if(!$logged_in){ echo 'wasn\'t able to log in'; exit(); } Edited November 8, 2012 by MMDE Quote Link to comment https://forums.phpfreaks.com/topic/270450-ftp_login-login-error-php/#findComment-1391184 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.