Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

New Server Problems

Options
  • 07-12-2006 4:52pm
    #1
    Registered Users Posts: 673 ✭✭✭


    Hey,

    Can someone tell me is the error below is a problem with the server im running the code on or could it be a problem with my coding?

    here is my line of code:
    include_once $_SERVER.'/stafford_scripts/header.php';

    Thanks
    Notice: Undefined index: DOCUMENT_ROOT in d:\Domains\mywebsite.ie\wwwroot\my_website\register_script.php on line 2
    
    Warning: include_once(/stafford_scripts/header.php) [function.include-once]: failed to open stream: No such file or directory in d:\Domains\mywebsite.ie\wwwroot\my_website\register_script.php on line 2
    

    I am reusing alot of code i have from an old site but this is on a different server with a different hosting company and im running into problems. Another problem is this line of code:

    $current_url = selfURL();
    echo $current_url;

    which gets the current url of the page that is open and just echo's it. This worked fine on the old site but now im getting this error:

    Fatal error: Call to undefined function selfURL()


Comments

  • Registered Users Posts: 2,157 ✭✭✭Serbian


    I'd imagine the two problems are related. You are trying to include a PHP file which is not in the location you have specified in the first section. If you have access to the server itself, try printing out the location and seeing if it's correct:

    [php]print $_SERVER.'/stafford_scripts/header.php';[/php]

    The second function you have referenced is a custom function and not something that is built into PHP. I would imagine that the function declaration is probably in the file that is not being included which would explain why it's not working now.

    Edit: Personally, I wouldn't reference include files by their absolute path in the operating system, I would reference them relative to where they are in the site structure, it's just less confusing that way. This is assuming that the includes are reachable from the current site.

    [php]
    /* This is how I would do it */
    include ('includes/somefile.php');
    [/php]


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Thanks, got it working now


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Well nearly!!

    I have the function being called now:

    <?
    function curPageURL() {
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
    }
    ?>

    but now im getting the following error:

    Notice: Undefined index: REQUEST_URI in

    I presume this is because my server doesnt provide a variable called REQUEST_URI. Is their anything i can do about this?


  • Registered Users Posts: 2,157 ✭✭✭Serbian


    Odd that REQUEST_URI isn't there. The following will give you the same thing:

    [php]$_SERVER;
    $_SERVER;
    $_SERVER;
    $_SERVER;
    [/php]


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Thanks again, thats working now. I thought reusing the code would be easy :confused:


  • Advertisement
  • Registered Users Posts: 2,157 ✭✭✭Serbian


    Thanks again, thats working now. I thought reusing the code would be easy :confused:

    Usually it is. Apparently the problem above is related to IIS5 (Windows 2k / Windows 2k Server) as in it doesn't supply the REQUEST_URI parameter. I assume that's what you are using?


  • Closed Accounts Posts: 119 ✭✭frodo_dcu


    yea i got stuck for ages trying to figure that one out before, god dam microsoft, can't follow standerds


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Dont know what the last server was running on but this one is Helm. Im getting different error reporting settings than the last server as well. Doh!!


Advertisement