Re: FTP Class Connection Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ron Piggott wrote:

> PHP Warning:  ftp_login() expects parameter 1 to be resource, boolean given 
>
> [...]
>
>     /**
>      * Set FTP Login
>      *
>      * @param string $username
>      * @param string $password
>      *
>      * @return $this
>      */
>     public function setFtpLogin( $username , $password ) {
> 
>         $this->connection = ftp_login( $this->getFtpConnection() , $username , $password );
> 
>         return $this;
> 
>     }

The return value of ftp_login() is a boolean value, but you're assigning
it to $this->connection.  Any further attempt to read $this->connection
will return this boolean value instead of the resource.  So you should
not change $this->connection in this method.

Furthermore you should either return the return value of ftp_login()
from this method, or preferably throw an exception if the login fails.
At least, as it's now, you'll never know whether the login succeeded,
and may get hard to find errors in the following.

-- 
Christoph M. Becker


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux