I'm working with some website. There's a script that sends the file to the ftp server. The script is executed completely and it shouldn't be because of bad credentials. Here is a code snippet from the script:
// FTP
$host = 'ftp.some.com';
$user = 'user1';
$pass = 'tes22';
$conn = ftp_connect($host, 21) or die ("Cannot connect to host");
ftp_login($conn, $user, $pass) or die("Cannot login");
echo 'it is shown and shouldn\'t be';
The real credentials are of course different, but they are bad (I can't connect to this FTP via Filezilla or even ping it. So the server should return the 'Cannot connect to host' message from the die() method but it doesn't --> echo is executed. How to debug something like this? What can be some possible issues of such behavior?
I've tried to execute this snippet. On line 8 you're trying to log-in or die. But, ftp_login
? in case of error, throws php warning. Example in psysh:
>>> ftp_login($conn, $user, $pass) or die("Cannot login");
PHP warning: ftp_login(): Login incorrect. on line 1
So, second operand after or
shouldn't work cause ftp_login
throws error.