Jump to content

ftp_login() failure - escaping of special chartacters?


dbrb2

Recommended Posts

Hi,

 

I have an ftp server, with a username of the form:

 

abcd@defg

and a password both alphanumeric and non-alphanumeric characters

 

If I log into the server from the command line (linux),  all is fine

If I try the same credentials using ftp_login(), then I reliably vget authentication failure

 

Does ftp_login need credentials to be escaped in some way?

$ftp_server="1.2.3.4";

$ftp_user_name="[email protected]";

$ftp_user_pass="abc@cde*#";

$ftp_port=21;

 

$conn_id = ftp_connect($ftp_server,$ftp_port,30) or die("Couldn't connect");

$login_result = ftp_login ($conn_id,$ftp_user_name,$ftp_user_pass);

print_r($login_result);

ftp_close($conn_id);

 

I have also tried using ftp_raw - I think it may be the @ in the username causing problems. However, my attempts to escape it thus far have failed. For instance, replacing it with '%40' gives:

 

ftp_login(): Syntax error in parameters or arguments

 

Any ideas?

No - however I have it sorted

I ran wireshark up whilst trying from the command line (OK) and php (not OK)

 

The difference was obvious - the password contained a $ sign, which was being treated as a special character by php. Esacaping it with a \ character, all is now fine!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.