February 12th, 2013, 12:59 AM
Can't use ftp_coonect to connect and copy
I see a blank page and no files gets copied anywhere! What am I doing wrong?
$c = ftp_connect('ftp.flatmates.com') or die("Can't connect") ;
ftp_login($c,'...','...') or die('Can\'t login');
ftp_put($c,'about.php','about.php_copy', FTP_ASCII) or die('Can\'t copy');
Last edited by requinix; February 12th, 2013 at 05:16 PM.
Reason: credentials, dood
February 12th, 2013, 09:24 AM
php > $c = ftp_connect('ftp.flatmates.com') or die("Can't connect") ;
PHP Warning: ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in php shell code on line 1
Comments on this post
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question
or you're a Help Vampire.
Trying to argue intelligently? Please read this.
February 17th, 2013, 05:06 PM
Originally Posted by ManiacDan
Would you please tell me why I don't get the warning you get?
Would it make a difference if I run the code from terminal?
@ptr2: Hey buddy my English is not the best. I assume you are being sarcastic aren't you? Are you asking for the credentials to my server? What is the point of your comment?
February 17th, 2013, 05:12 PM
No, you POSTED your credentials in your original post. requinix was kind enough to remove them before some random dude used them. Probably should still change them, in case someone grabbed them.
I ♥ ManiacDan & requinix
This is a sig, and not necessarily
a comment on the OP:
don't be a help vampire
February 17th, 2013, 05:27 PM
Is there anything else to the script? You only posted a few lines from it - I don't see any <?php or ?> tags. Could be there's a syntax error (or some other error) stopping execution.
Originally Posted by zxcvbnm
Also, add an echo after the ftp_close() and look for that message.
Regarding the username and password, I removed them 16 hours after you posted. That's more than enough time for search engines to come here, grab the content, cache it, and serve it to anybody who uses the right search terms. Like ptr2void said you should definitely change them; at least the password, and not just for the FTP account but anywhere else you may use them too.
February 17th, 2013, 07:33 PM
A few things:
1 - I never put the correct server details in the forum. I always change them, same with the server location, domain name and others. But thank you for your concern and looking after me.
2 - I use the code below and I get no errors, I actually get the Copied message now but I can't see the file copied there in the folder. The folder exists and it is 777. Can anyone see what is wrong? Thank you
The code below prints:
$connected = ftp_connect('ftp.domainname.com') or die("Can't connect") ;
echo "Connected<br />";
echo "Can't connect<br />";
$logged = ftp_login($connected,'username','password') or die('Can\'t login');
echo "Logged<br />";
echo "Can't log in<br />";
$copy = ftp_put($connected,'copy_here','local_file.php', FTP_ASCII) or die('Can\'t copy');
echo "Copied<br />";
echo "Not Copied<br />";
February 18th, 2013, 05:27 AM
Can anyone please answer this?
Originally Posted by zxcvbnm