Jump to content

Recommended Posts

Posted

Hi,

 

I'm getting an error on a page that uses "include" functions. Both of the lines mentioned correspond with my php code which is

><?php
include $_server['document_root']."inc/PHhead.php";    //line 14
?>

and

><?php
include $_server['document_root']."inc/PHfoot.php";     //line 41
?>

 

The errors (notices) are at the top of the page:

Notice: Undefined variable: _server in C:\Inetpub\Pioneershospital\index.php on line 14

Notice: Undefined variable:_server in C:\Inetpub\Pioneershospital\index.php on line 41

 

Now...this site is not on the TCH servers. I did all I could to get them to use TCH for hosting...but, it didn't happen. So...since I use this same code on my TCH sites with no problems...I'm wondering if it is not something on the server end of things. The person that handles this particular account had no answers, though. He seemed to know less about PHP than I do...which is not all that much.

 

The page works...the includes work...I just don't know how to get that notice off the top of the page, or why it is there in the first place. You can view the page here.

 

I will be gone until tomorrow evening, so if you need more information from me, I will get it tomorrow.

 

Thanks,

Tracy

Posted (edited)

I'm not sure if this is the cause... but you might try capitalizing SERVER and adding a forward slash in front of inc.

 

<?php

include $_SERVER['document_root']."/inc/PHhead.php";    //line 14

?>

 

If that doesn't work, then try using the absolute url.

 

like... htttp://www.whatever.com/inc/PHhead.php

Edited by surefire
Posted

Thanks, Jack. The absolute url works fine, but that means that when the hospital points their ".com" domain over to this account, I will have to change 70+ pages of php code. Which probably isn't all that hard to do in Dreamweaver...but I'd rather not if I can get around it.

 

I had already tried the slash in front of inc and that didn't work. It doesn't find the include file at all when I do it that way. I capitalized _SERVER and the "notice" changed to

Notice: Undefined index: document_root in C:\Inetpub\Pioneershospital\index.php on line 14

 

I also tried both upper and lower case for "document_root" and it didn't make a difference. I did forget to mention earlier that this company is running PHP 3. Would that be causing this error?

 

Thanks,

Tracy

Posted

Tracy, I don't know if you can ftp a page to their site. If you can, upload an info page.

 

><?php
phpinfo();
?>

 

I would be willing to bet that they are using an older version of PHP.

 

If that's the case... then maybe this will help

 

>For those of us who don't have the luxery of upgrading to the latest version of PHP on all of the servers we use but want to use the same variable names that are used in the latest version for super global arrays here's a snippet of code that will help:
   // Makes available those super global arrays that are made available
   // in versions of PHP after v4.1.0.
   if (isset ($HTTP_SERVER_VARS))
   {
       $_SERVER = &$HTTP_SERVER_VARS;
   }
  
   if (isset ($HTTP_GET_VARS))
   {
       $_GET = &$HTTP_GET_VARS;
   }
  
   if (isset ($HTTP_POST_VARS))
   {
       $_POST = &$HTTP_POST_VARS;
   }
  
   if (isset ($HTTP_COOKIE_VARS))
   {
       $_COOKIE = &$HTTP_COOKIE_VARS;
   }
  
   if (isset ($HTTP_POST_FILES))
   {
       $_FILES = &$HTTP_POST_FILES;
   }
  
   if (isset ($HTTP_ENV_VARS))
   {
       $_ENV = &$HTTP_ENV_VARS;
   }
  
   if (isset ($HTTP_SESSION_VARS))
   {
       $_SESSION = &$HTTP_SESSION_VARS;
   }
The only downfall to this is that there's no way to make them super global. Chances are, though, if you're using a lot of global arrays in your code you should consider a code redesign!  :)  Hope this helps.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...