#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,660
    Rep Power
    171

    Can't use ftp_coonect to connect and copy


    Hello;

    I see a blank page and no files gets copied anywhere! What am I doing wrong?
    PHP Code:
    error_reporting(-1);
    $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');
    ftp_close($c); 
    Last edited by requinix; February 12th, 2013 at 04:16 PM. Reason: credentials, dood
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Code:
    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

    • ptr2void agrees : Probably a good thing, what with the apparent broadcasting of his credentials :rolleyes:
    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.
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,660
    Rep Power
    171
    Originally Posted by ManiacDan
    Code:
    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
    Hello Dan;
    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?

    Thanks guys
  6. #4
  7. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,549
    Rep Power
    2337
    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:
    Please don't be a help vampire!
  8. #5
  9. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,056
    Rep Power
    9398
    Originally Posted by zxcvbnm
    Hello Dan;
    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?
    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.
    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.
  10. #6
  11. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,660
    Rep Power
    171
    Hello gang;

    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:
    Code:
    Connected
    Logged
    Copied
    1
    PHP Code:
    <?php error_reporting(-1);
    $connected ftp_connect('ftp.domainname.com') or die("Can't connect") ;
    if(
    $connected)
        {
            echo 
    "Connected<br />";    
        }
    else
        {
            echo 
    "Can't connect<br />";    
        }
    $logged ftp_login($connected,'username','password') or die('Can\'t login');
    if(
    $logged)
        {
            echo 
    "Logged<br />";    
        }
    else
        {
            echo 
    "Can't log in<br />";    
        }
    $copy ftp_put($connected,'copy_here','local_file.php'FTP_ASCII) or die('Can\'t copy');
    if(
    $copy)
        {
            echo 
    "Copied<br />";    
        }
    else
        {
            echo 
    "Not Copied<br />";    
        }
    echo 
    ftp_close($c);?>
  12. #7
  13. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,660
    Rep Power
    171
    Originally Posted by zxcvbnm
    - 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:
    Code:
    Connected
    Logged
    Copied
    1
    PHP Code:
    <?php error_reporting(-1);
    $connected ftp_connect('ftp.domainname.com') or die("Can't connect") ;
    if(
    $connected)
        {
            echo 
    "Connected<br />";    
        }
    else
        {
            echo 
    "Can't connect<br />";    
        }
    $logged ftp_login($connected,'username','password') or die('Can\'t login');
    if(
    $logged)
        {
            echo 
    "Logged<br />";    
        }
    else
        {
            echo 
    "Can't log in<br />";    
        }
    $copy ftp_put($connected,'copy_here','local_file.php'FTP_ASCII) or die('Can\'t copy');
    if(
    $copy)
        {
            echo 
    "Copied<br />";    
        }
    else
        {
            echo 
    "Not Copied<br />";    
        }
    echo 
    ftp_close($c);?>
    Can anyone please answer this?

    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo