dbrb2 Posted July 3, 2012 Share Posted July 3, 2012 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? Link to comment https://forums.phpfreaks.com/topic/265155-ftp_login-failure-escaping-of-special-chartacters/ Share on other sites More sharing options...
scootstah Posted July 3, 2012 Share Posted July 3, 2012 Post the code please. Link to comment https://forums.phpfreaks.com/topic/265155-ftp_login-failure-escaping-of-special-chartacters/#findComment-1358798 Share on other sites More sharing options...
dbrb2 Posted July 3, 2012 Author Share Posted July 3, 2012 $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? Link to comment https://forums.phpfreaks.com/topic/265155-ftp_login-failure-escaping-of-special-chartacters/#findComment-1358801 Share on other sites More sharing options...
scootstah Posted July 3, 2012 Share Posted July 3, 2012 Have you tried the username without the host attached? Link to comment https://forums.phpfreaks.com/topic/265155-ftp_login-failure-escaping-of-special-chartacters/#findComment-1358803 Share on other sites More sharing options...
dbrb2 Posted July 3, 2012 Author Share Posted July 3, 2012 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! Link to comment https://forums.phpfreaks.com/topic/265155-ftp_login-failure-escaping-of-special-chartacters/#findComment-1358805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.