Jump to content

Problem with path


doubledee

Recommended Posts

In NetBeans - in what I think is the Web Root - I have...

 

config.inc.php

secure/checkout.php

 

In "checkout.php", when I use this code it works...

 

<?php	require_once "../config.inc.php";	?>

 

but when I try to use an Absolute Path, it errors out...

 

<?php	require_once "/config.inc.php";	?>

 

 

I thought "/" moved you up to the Web Root and then you drill down from there?

 

So the second example should also work in my mind?!

 

What is wrong?

 

 

 

Debbie

 

 

Link to comment
Share on other sites

Using a slash at the start of a path like that, say to start at the root of the whole file system, which is not what you want.

 

You want to do something like

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/config.inc.php';
?>

 

If your file is in the webroot.

 

Ken

Link to comment
Share on other sites

Ken,

 

I could really use some more help on this topic.  (Now that my website is more than one page and has lots of includes, I've got a real disaster here.)  :(

 

This all started when I broke up my home page of which most of the code reappears in other pages.  So I created a series of includes like...

 

header.inc.php

left_col.inc.php

right_col.inc.php

footer.inc.php

 

The problem is that files from different directory locations all need a "header.inc.php" which is what brought me to a grinding halt today!  :(

 

Here is a sample of what I have...

 

00_MyWebsite
Source Files
	components
		body_header.inc.php
		body_footer.inc.php

	secure
		checkout.php

	images
		my_logo.png

	index.php
	product_details.php

 

 

Here is where I need help...

 

In my web root (locally), I have...

 

"index.php" which includes "body_header.inc.php" which has an img link to "images/my_logo.png"

 

 

But then I also have "secure/checkout.php" includes "body_header.inc.php" which has an img link to "images/my_logo.png".

 

When that happens, I have a major issue!!

 

 

Things are further complicated by the fact that my "Web Root" is different in NetBeans than on my WebHost...

 

(I don't have the know-how to do anything on my server, so for now I'm looking for an easier way to make my includes behave and easily transition from my Dev Laptop to my Live Web Host.)

 

Please help!!!

 

 

 

Debbie

 

Link to comment
Share on other sites

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.