"notice" Problem In Php

liunx

Guest
Hi, <br /><br />I'm getting an error on a page that uses "include" functions. Both of the lines mentioned correspond with my php code which is<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />include $_server['document_root']."inc/PHhead.php";    //line 14<br />?><!--c2--></div><!--ec2--><br />and<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />include $_server['document_root']."inc/PHfoot.php";     //line 41<br />?><!--c2--></div><!--ec2--><br /><br />The errors (notices) are at the top of the page:<br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Notice: Undefined variable: _server in C:\Inetpub\Pioneershospital\index.php on line 14<br />Notice: Undefined variable:_server in C:\Inetpub\Pioneershospital\index.php on line 41<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />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.<br /><br />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. <a href="http://www.pioneershospital.net" target="_blank">You can view the page here.</a><br /><br />I will be gone until tomorrow evening, so if you need more information from me, I will get it tomorrow.<br /><br />Thanks,<br />Tracy<!--content-->
I'm not sure if this is the cause... but you might try capitalizing SERVER and adding a forward slash in front of inc.<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec--><?php<br />include $_SERVER['document_root']."/inc/PHhead.php";    //line 14<br />?><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />If that doesn't work, then try using the absolute url. <br /><br />like... <!-- m --><a class="postlink" href="htttp://www.whatever.com/inc/PHhead.php">htttp://www.whatever.com/inc/PHhead.php</a><!-- m --><!--content-->
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. <br /><br />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<br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Notice: Undefined index: document_root in C:\Inetpub\Pioneershospital\index.php on line 14<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />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?<br /><br />Thanks,<br />Tracy<!--content-->
Tracy, I don't know if you can ftp a page to their site. If you can, upload an info page.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />phpinfo();<br />?><!--c2--></div><!--ec2--><br /><br />I would be willing to bet that they are using an older version of PHP.<br /><br />If that's the case... then maybe this will help<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->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:<br />    // Makes available those super global arrays that are made available<br />    // in versions of PHP after v4.1.0.<br />    if (isset ($HTTP_SERVER_VARS))<br />    {<br />        $_SERVER = &$HTTP_SERVER_VARS;<br />    }<br />   <br />    if (isset ($HTTP_GET_VARS))<br />    {<br />        $_GET = &$HTTP_GET_VARS;<br />    }<br />   <br />    if (isset ($HTTP_POST_VARS))<br />    {<br />        $_POST = &$HTTP_POST_VARS;<br />    }<br />   <br />    if (isset ($HTTP_COOKIE_VARS))<br />    {<br />        $_COOKIE = &$HTTP_COOKIE_VARS;<br />    }<br />   <br />    if (isset ($HTTP_POST_FILES))<br />    {<br />        $_FILES = &$HTTP_POST_FILES;<br />    }<br />   <br />    if (isset ($HTTP_ENV_VARS))<br />    {<br />        $_ENV = &$HTTP_ENV_VARS;<br />    }<br />   <br />    if (isset ($HTTP_SESSION_VARS))<br />    {<br />        $_SESSION = &$HTTP_SESSION_VARS;<br />    }<br />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.<!--c2--></div><!--ec2--><!--content-->
 
Top