Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/270450-ftp_login-login-error-php/
Share on other sites

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 by MMDE
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.