Jump to content

Recommended Posts

Ok I have been running a script for several months now and all of a sudden I get a 500 error.

 

I think this error corresponds to the server admin upgrading there version of php.

 

I have tracked down the problem to my 'required_once' statements. the php script included by the 'required_once' is executing however no variables set in the included script are being passed back to the including script.

 

Example.

 

index.php

<?php
require_once('http://' . $_SERVER["HTTP_HOST"] . '/settings/dj-config.php');// Configuration and Global variable Declarations

echo 'ROOT = ' . ROOT . '<br>';
echo '$root = ' . $root . '<br>';

?>

 

dj-config.php

<?php

define (ROOT, 'http://' . $_SERVER["HTTP_HOST"] . '/');

$root = 'Hello Would!';

?>

 

Run Script

ROOT = ROOT
$root = 

 

Both allow_url_fopen and allow_url_include are turned on,

 

Are there any other php settings that could be causing this behaviour?

 

Thanks,

Levi

Link to comment
https://forums.phpfreaks.com/topic/88654-solved-required_once-problem/
Share on other sites

This application has a complex directory structure, I just found it an easy way to keep track of script paths

 

Include('http://' . $_SERVER["HTTP_HOST"] . '/include/gui/tables.php)

 

Is simpler to read than

 

Include(../../../../include/gui/tables.php)

i just like reading paths from the root derectory.

 

I usualy include paths like this

 

define('ABSPATH', dirname(__FILE__).'/');//setup in my config.php

Include(ABSPATH . 'include/gui/tables.php)//include from in all other php files

 

if you have a better approach I would love to see.

 

PS, Problem solved PHP just need to be recompiled with apache.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.