January 23rd, 2005, 02:15 PM
Warning: ftp_login() expects parameter 1 to be resource, boolean given ...
I recently am having a problem with a php-triggered ftp-upload script, that keeps giving me that error, even though it worked fine before and I didnīt do any changes.
"Warning: ftp_login() expects parameter 1 to be resource, boolean given in script.php on line 98
Warning: ftp_pasv() expects parameter 1 to be resource, boolean given in script.php on line 99
Warning: ftp_put() expects parameter 1 to be resource, boolean given in script.php on line 102
Here is the matching part of the php-code:
Does anyone probably know what that error messages mean?
$FTPserver = "ftpserver";
$ftp = ftp_connect($FTPserver);
$login = ftp_login($ftp, $FTPuser, $FTPpass);
$modus = ftp_pasv($ftp, 1);
January 23rd, 2005, 02:32 PM
The functions wanted first parameter(argument) as a FTP-resource ie. link identifier but they got a boolean value ie. FALSE.
I guess, your code could be :
The problem has it basis in the fact that, when ftp_connect() cannot connect to a FTP Server it returns FALSE instead of the resource link identifier it generally returns. Check whether your FTP server is alive using ping.
$ftp = ftp_connect($FTPserver) or die ("Can't connect to FTP Server : $FTPserver");
$login = ftp_login($ftp, $FTPuser, $FTPpass) or die ("Can't login to FTP Server : $FTPServer");
-- Knight Samar
January 23rd, 2005, 02:34 PM
thx so the basis of the problem is that it cannot connect to the ftp-server?
best regards, pdoms
January 23rd, 2005, 02:48 PM
changed the host for the ftp now a little (to the by the provider suggested url), but funny thing now is that sometimes I get that error sometimes not. The only pattern I could detect behind that is, that if I donīt use the script for like 10 minutes it would work the first time but every time after it wonīt work any more if I donīt wait 10 minutes again to run the script. Does that make sense to any of you?
January 23rd, 2005, 03:00 PM
Yes, that must be so, I would say. Try echoing $ftp or using the die() function.
Originally Posted by pdoms
January 23rd, 2005, 03:09 PM
do you have any idea on what could cause it to sometimes work and sometimes donīt even when using the exact same script with exact same data?
best regards, pdoms
January 23rd, 2005, 03:56 PM
I guess, it could be the server itself. Prolly you aren't closing the connection properly and the the server doesn't accept more than one connection from a user at a time and its timeout is set to 10 minutes after which you are able to connect.
I really don't know,pdoms. You could ask the provider himself, he might or should know.
January 23rd, 2005, 06:28 PM
ok will try that, thx for the help
I always close the ftp-connection by ftp_quit($ftp), I guess that should work?
April 25th, 2005, 05:19 PM
I had the same f*kin' problem, then I try to connect directly from the server with a console, but It was my server that has time out problems....
if anyone had this kind of problem, try connecting directly from your host server to your FTP server...
regards to all...