Problem with ftp_connect and gethostbyname on PHP 4

Posted on 2005-05-13
Last Modified: 2013-12-13
I've got this error message :
Warning: ftp_connect(): php_network_getaddresses: gethostbyname failed in xxxxxxxxxxxxxxxxxxx

Here the code :

// set up basic connection
$ftp_server = "";

$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); ;

// login with username and password
$login_result = ftp_login($conn_id, "anonymous", "");

// get contents of the current directory
$contents = ftp_nlist($conn_id, "./ss/Parachiot/");

// output $contents


** Question PAQ'd and points refunded as the asker found solution himself - ldbkutty/Page Editor **
Question by:bruno_boccara
    1 Comment

    Accepted Solution

    That's ok I've got the answer.

    its because we don't need to put ftp:// in $ftp_server.

    the good syntax is $ftp_server = "";

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now