PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Oct 18, 2018 1:11 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problem with SITE_ROOT
PostPosted: Wed Mar 14, 2018 11:00 am 
Offline
Forum Newbie

Joined: Wed Mar 14, 2018 10:59 am
Posts: 1
I am teaching myself php (working through a textbook) and have hit a couple of problems. I've just spent about 4 hours trying to get the SITE_ROOT configured. I have selected public_html/exercises as the ROOT using

define("SITE_ROOT", "/public_html/exercises/");

Now, I on error I want to redirect to public_html/exercises/scripts/show_error.php. I'm using

function handle_error ($user_error_message, $system_error_message) {
header("Location: " . SITE_ROOT . "scripts/show_error.php?" . "error_message={$user_error_message}&" . "system_error_message={$system_error_message}");
exit();
to do that but each time I get

The requested URL /public_html/exercises/scripts/show_error.php was not found on this server.

What am I doing wrong?


Top
 Profile  
 
PostPosted: Wed Mar 14, 2018 2:04 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13580
Location: New York, NY, US
You have defined your SITE_ROOT as a file system path:
Syntax: [ Download ] [ Hide ]
define("SITE_ROOT", "/public_html/exercises/");

However, in your function you are using it as a URL:
Syntax: [ Download ] [ Hide ]
header("Location: " . SITE_ROOT . "scripts/show_error.php?" . "error_message={$user_error_message}&" . "system_error_message=

You probably want to define it as a URL instead:
Syntax: [ Download ] [ Hide ]
define("SITE_ROOT", "http://mysite.com/exercises/");

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group