Jump to content

Recommended Posts

Okay I posted the other day got some answers, but still have pathway issues.

 

I am getting the following error:

 

Warning: require_once(/innovationation1/commonResources/includes/headerArea.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\innovationation1\newsPages\newsArticles.php on line 2

 

Fatal error: require_once() [function.require]: Failed opening required '/innovationation1/commonResources/includes/headerArea.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\innovationation1\newsPages\newsArticles.php on line 2

 

It is basically not finding the correct pathway, when I go into a sub-directory with a URL like this;

 

http://localhost/innovationation1/newsPages/newsArticles.php

 

This is my current require_once statement that is load the dbConnection class. I have tried removing the first bit "/innovationation1", as well as a number of other things are suggestions how to fix this?

 

<?php require_once '/innovationation1/commonResources/dbConnection/dbConnection.php'; ?>

Link to comment
https://forums.phpfreaks.com/topic/239542-pathway-issues-again/
Share on other sites

A leading / on a file system path refers to the root of the current hard disk.

 

You can use $_SERVER['DOCUMENT_ROOT'] to get the file system path to your document root folder, then concatenate the rest of the path to your file to that value to arrive at an absolute file system path.

The pathway in the terms of when it's stored on my computer is: C:xampp/htdocs/innovationation1/commonResources/dbConnection/dbConnection.php

 

I was using $_SERVER["DCOUMENT_ROOT"], but this was presenting issues with <a href=""> </a> links and someone advised me not to use them for normal links so I took them out of the site completely. So was that correct? Or does is it different in the terms of require_once?

 

The dbConnection.php require_once is used within headerArea.php which should be the same pathway location thorughout the site, and it works fine on a the top level ie no sub folders, but once we get into them the issues start happening.

The pathway in the terms of when it's stored on my computer is: C:xampp/htdocs/innovationation1/commonResources/dbConnection/dbConnection.php

 

I was using $_SERVER["DCOUMENT_ROOT"], but this was presenting issues with <a href=""> </a> links and someone advised me not to use them for normal links so I took them out of the site completely. So was that correct? Or does is it different in the terms of require_once?

 

The dbConnection.php require_once is used within headerArea.php which should be the same pathway location thorughout the site, and it works fine on a the top level ie no sub folders, but once we get into them the issues start happening.

links have absolutely nothing to do with file system paths, using $_SERVER['DOCUMENT_ROOT'] as PFM said should be sufficient

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.