title: How can I gracefully handle php ftp login error
body: <p>I get a server error on the ftp_login line of the following code. How can I gracefully handle connection/login failure?</p>
  
  <pre><code>$serverAddress = 'ftp.someServerAddress';
  $connId = ftp_connect($serverAddress);
  if($connId) {
      if (ftp_login($connId, 'UserName', 'password')) {
          // do some stuff
      } else {
          echo 'login failed';
      }
  } else {
      echo 'connection failed';
  }
  </code></pre>