php_network_getaddresses, help

Discussion in 'PHP' started by dipoer, Jun 1, 2007.

  1. #1
    Hi. I'm new to PHP and writing a script for myself.

    I have a settings.php which contains the informations of my site. (included all pages)

    <?php
    $siteurl = "www.sitename.com";
    etc.etc.
    ?>

    I've put my site's link into it. It works on localhost but doesn't work on the server. The firm said they blocked php_network_getaddresses function in order to protect hostings from hacking attacks, is that right? If so, what can I do else? I have main php files, I call 4 included pages (like header, footer etc)

    This is how I use the code,

    <?php include("$siteurl./include/header.php"); ?>

    and
    This is the warning I get

    Warning: main() [function.main]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/dipoer/public_html/script/demo/index.php
    Code (markup):
     
    dipoer, Jun 1, 2007 IP
  2. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Don't use URLs in your includes(), use system file path instead eg. include('/home/myaccount/includes/whatever.php');
     
    mrmonster, Jun 1, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Don't use them anyways, even if they are allowed by your host, as they add to processing load, as PHP wastes time only to figure out the file is on the same server as the script. If you must use absolute paths, use something like $siteroot instead of $siteurl with $siteroot being the document root, which is available in the PHP $_SERVER array: $_SERVER['DOCUMENT_ROOT']

    <?php
    $siteroot = $_SERVER['DOCUMENT_ROOT'];
    ?>
    
    // ...
    
    <?php
    include("$siteroot/include/header.php");
    ?>
    PHP:
     
    krt, Jun 1, 2007 IP
  4. dipoer

    dipoer Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you guys. That solved my problem.
     
    dipoer, Jun 2, 2007 IP