0

I don't know why i can't get a successful ftp_login. All informations about my server are good but $connect fails.

Here is my code:

$connect = ftp_connect('myserver.1and1-data.host', 22, 5);
$login = ftp_login($connect, 'username', 'password');

I have this error:

PHP Warning:  ftp_login() expects parameter 1 to be resource, bool given in C:\\...

I have to put 22 as port or i have an error.

I've tried to connect with the same informations with FileZilla and it works.

So do you know what am i doing wrong ?

Thanks :)

  • 1
    Generally, getting a "bool given" means the function that produced the value has failed. So here, your `ftp_connect()` has failed, returned `false`, which you then pass into `ftp_login()`. – droopsnoot Apr 27 '20 at 11:07
  • "I have to put 22 as port or i have an error." isn't sufficiently detailed for a useful answer. – mario Apr 27 '20 at 11:12
  • Thanks for your answer @droopsnoot ! But i understood that my connection has failed but i don't understand why because all informations about my server are good... – Sacha COHEN Apr 27 '20 at 11:13
  • @mario if i don't put a port, it will use by default 21 port and my FTP Server is on 22 port – Sacha COHEN Apr 27 '20 at 11:14
  • Somewhat unlikely that port 22 is occupied by a FTP server. See last duplicate listed. – mario Apr 27 '20 at 11:15

0 Answers0