Jump to content

includes


krash11554

Recommended Posts

ok my so i moved one of my pages (settings.php) for my website into a folder called edit in the main directory so the url would look like main/edit/settings.php. now my includes on that page are coming up as errors. idk why. the includes paths are main/includes/overall/overallheader.php and i also have includes for the settigings page which is main/includes/settingsincludes/header.php. now the error is saying Failed opening 'includes/overall/overallheader.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\main\edit\profileinfo.php on line 2 and it also says that for the footer and the settings includes . HELP.

Link to comment
Share on other sites

When you moved the 'settings.php' file inside another folder, did you change the pathway of your 'include' statements? If not, you should add " ../ " to your pathways. That will back up out of the new folder (directory) you put the file in.

Link to comment
Share on other sites

When you move a file either into a new folder, or out of an old one, you have to re-assess all of its references ... images, links, includes ... everything ... but only in that one file. So, in your 'settings.php' file, if you had an 'include' statement that read INCLUDE 'SOME_FILE.PHP'; you would now need to add ../ to the beginning of it as such INCLUDE '../SOME_FILE.PHP';

 

If your settings file was referencing any images also or any other kind of resource (page, link, file, etc...) you're going to need to do the same there, also.

Link to comment
Share on other sites

Ok, you have a 'settings.php' file in a folder titled 'edit' AND you have an 'overallheader.php' file in a folder (overall) inside another folder (includes). Right? Okay, to reference the overallheader.php file from the settings.php file your include needs to look like this:

 

include '../includes/overall/overallheader.php';

 

This backs you out of the "edit" folder, and takes you through both the "includes" folder and the "overall" folder. If this isn't working, I think you might have different pathways than you have stated here.

Link to comment
Share on other sites

the overallheader file has two more files in it being included called head and header idk if that makes a difference because its still not working . where the head file is being included does that include need ../ to ? because i tried and when i do that it messed up basically all the other pages that i have for the website.

Thanks for your help so far.

Link to comment
Share on other sites

.. means "parent folder to where I am now"

. means "folder I am in now"

 

Used with a forward dir slash / for relative pathways, it's normally used for quick relativism.

 

I prefer to create constants.

define( APP_PATH, '/home/user/http/application/');

define( WEB_ROOT, '//example.com/');

 

include_once( APP_PATH . 'includes/my_functions.php');

Link to comment
Share on other sites

CSS files are requested by the client, so they need to know the URL at which to find the file. The same goes for images. You ideally should provide the full URL to the resource:

 

<link rel="stylesheet" href="http://www.your_domain.com/path/to/file/stylesheet.css">

 

To further what i stated before, you could do this on your pages easily with:

<link href "<?php echo WEB_PATH; ?>/assets/css/style.css" />

Link to comment
Share on other sites

<div id="infobar">


<div id="infobarborder">
	<div id="ullist">
	<ul>
		<li class="menu">
			<a class="menu" href="/garage/index.php">
			Home
			</a>
		</li>
		<li class="menu">
		<a class="menu" href="#">	
			Explore
		</a>	
		</li>
		<li class="menu">
			<a class="menu" href="login.php">
			LogIn
			</a>
		</li >
		<li class="menu">
			<a id="d"href="register.php">
			Register
			</a>
		</li>
	</ul>
	</div>	
		<div id="searchbar">
		<form id="search" action="" method="" >
			<input type="text" id='searchinput'  />
			<input type="submit" value="Go" id="submitinput" />
		</form>
		</div>
</div>
</div>

this is the menu im not sure what your asking to see

Link to comment
Share on other sites

sorry i was editing the wrong menu the linking is working. thank you so much. one more Q if you dont mind i have a head that contains the css files when i include it on the settings page it only works when i do this ../ to the url of the css . but it works fine on all the other pages.  I think someone said just give the whole url of the css file . Let me know if im doing it wrong. Thanks again

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.