Re: Global turned off



jpb wrote:
I quite new to PHP and little confused at the present about Global
variables.

My new host has them turned off and now some of my code will not work.

I had a line of code in a menu like this.

<a href="<?php echo
$config[baseurl]; ?>/template.php?story="/includes/lake.inc.php"
id="template"><?php echo("Residents call for cleanup") ;?></a>


The following lines are in the file template.php

$story = $HTTP_GET_VARS[ "story" ];


and


<?php include $config[baseurl].$story; ?>


When I try this I receive the following


Warning: include() [function.include]: URL file-access is disabled in
the server configuration
in /template.php on line 31

What is the proper way to include the wanted file now?

Thanks

This has nothing to do with globals (although you should have them turned off - see Klaus's comment). Rather, you are trying to include the file via a URL instead of using the local file system.

It's OK to include a file from a remote server that way (in fact, the only way you can do it if you don't have a shared file system). However, including it locally means an extra call to the web server, and the additional overhead involved.

Rather, you should be including it using the file system. You can find the root directory of your website with $_SERVER['DOCUMENT_ROOT'], so you would do something like:

include($_SERVER['DOCUMENT_ROOT'] . "/{$story}");

Also, $HTTP_GET_VARS has been deprecated and replaced by the $_GET superglobal array; you should be using that instead (same with $HTTP_POST_VARS and $HTTP_COOKIE_VARS).


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.