Support » Installing WordPress » $_server (script uri, query string, etc) – unable to retieve

  • Resolved JRPereira


    For some reason or another I can’t seem to access (just returns blank) $_SERVER variables to use with my stats system – it’s only been happening since I started using wordpress, and I’ve made sure to clear any rewrites/etc out of my .htaccess and the httpd.conf itself. WordPress appears to be doing something with those variables (with varying things like the REMOTE_ADDR being available depending on where I require() the stats update code (which basically just tosses up another row in a mysql table.

    Since I’m not really sure what wordpress is doing, I’m kind of at a standstill scratching my head and wondering what to do.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Uh woops can somebody move this topic to the right subforum?

    This may have something to do with WordPress’s deregistering globals. Are you trying to access them like $REMOTE_ADDR? That would do it. Try using the normal way of $_SERVER[‘REMOTE_ADDR’] …

    Also, you could try adding print_r($_SERVER) and seeing if there’s any data there.


    I tried both $remote_addr and $_server[‘remote_addr’] – I’ll try print_r and see what happens.

    This is the result: Looks like script URI no longer exists, along with a few other things. It’s enough to work with, so thanks a ton, but I have to say it’s odd that some of the variables are being completely erased.

    [DOCUMENT_ROOT] => /home/wwu/public_html/justinpereira
    [HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/, application/, application/msword, */*
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_CONNECTION] => Keep-Alive
    [HTTP_HOST] =>
    [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)
    [PATH] => /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
    [REDIRECT_QUERY_STRING] => page_id=283
    [REDIRECT_STATUS] => 200
    [REDIRECT_URL] => /
    [REMOTE_ADDR] =>
    [REMOTE_PORT] => 2788
    [SCRIPT_FILENAME] => /home/wwu/public_html/justinpereira/index.php
    [SERVER_ADDR] =>
    [SERVER_NAME] =>
    [SERVER_PORT] => 80
    [SERVER_SOFTWARE] => Apache
    [QUERY_STRING] => page_id=283
    [REQUEST_URI] => /?page_id=283
    [SCRIPT_NAME] => /index.php
    [PATH_TRANSLATED] => /home/wwu/public_html/justinpereira/index.php
    [PHP_SELF] => /index.php
    [argv] => Array
    [0] => page_id=283

    [argc] => 1

    By the way, thanks a TON for showing me the print_r function.

    Remember, the $_SERVER global must be in ALL CAPS. And so do it’s children like REMOTE_ADDR. Saying $_SERVER[‘remote_addr’] will turn up nothing

    Aye, that print_r() is a handy one. There’s also var_dump(), but I usually find that you can get the info needed from print_r.

    Also, when I’m debugging, I’ve got this little function called echo_r(). It does the same thing as print_r() except it wraps it in <pre> tags.

    function echo_r($array) {
    echo "<pre>";
    echo "</pre>";

    That allows me to see the array nice and formatted.


    I have a similar issue to this … I have my print_r within a post using RunPHP.

    In my case i can see the output of the print_r shows that query_string is null even though my URI that i called the page with includes a query string. lots of the other values are being returned.

    My URI: http://localhost/wordpress/blog/category/sidebar/register/?var=value

    result of the print_r:

    [HTTP_HOST] => localhost
    [PATH] => C:\Program Files\Windows Resource Kits\Tools\;C:\Program Files\ThinkPad\Utilities;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IBM\Infoprint Select;C:\Notes;C:\Program Files\XLView;C:\lotus\compnent;C:\Utilities;C:\Program Files\IBM\Personal Communications\;C:\Program Files\IBM\Trace Facility\;C:\Program Files\ThinkPad\ConnectUtilities;C:\WINDOWS\Downloaded Program Files;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\ATI Technologies\ATI Control Panel
    [SystemRoot] => C:\WINDOWS
    [COMSPEC] => C:\WINDOWS\system32\cmd.exe
    Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6 Server at localhost Port 80

    [SERVER_SOFTWARE] => Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_autoindex_color PHP/5.1.6
    [SERVER_NAME] => localhost
    [SERVER_ADDR] =>
    [SERVER_PORT] => 80
    [REMOTE_ADDR] =>
    [DOCUMENT_ROOT] => C:/xampplite/htdocs
    [SERVER_ADMIN] => admin@localhost
    [SCRIPT_FILENAME] => C:/xampplite/htdocs/register.php
    [REMOTE_PORT] => 4340
    [REQUEST_URI] => /register.php
    [SCRIPT_NAME] => /register.php
    [PHP_SELF] => /register.php
    [REQUEST_TIME] => 1160425108
    [argv] => Array

    [argc] => 0

    in the header.php in my theme, i can see the var=value but in the page template page.php, the value is cleared.

    suggestions appreciateed. thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘$_server (script uri, query string, etc) – unable to retieve’ is closed to new replies.