krash11554 Posted August 4, 2012 Share Posted August 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/ Share on other sites More sharing options...
jandrews3 Posted August 4, 2012 Share Posted August 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366799 Share on other sites More sharing options...
krash11554 Posted August 4, 2012 Author Share Posted August 4, 2012 put this ../ on every include statement or just the ones on the settings.php page?? Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366800 Share on other sites More sharing options...
jandrews3 Posted August 4, 2012 Share Posted August 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366801 Share on other sites More sharing options...
krash11554 Posted August 4, 2012 Author Share Posted August 4, 2012 When i put ../ on the overallheader include on the settings page it now says cant find the head and header that was included in the overall header. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366802 Share on other sites More sharing options...
jandrews3 Posted August 4, 2012 Share Posted August 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366805 Share on other sites More sharing options...
Pikachu2000 Posted August 4, 2012 Share Posted August 4, 2012 include "{$_SERVER['DOCUMENT_ROOT']}/edit/settings.php"; Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366806 Share on other sites More sharing options...
krash11554 Posted August 4, 2012 Author Share Posted August 4, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366816 Share on other sites More sharing options...
Mahngiel Posted August 4, 2012 Share Posted August 4, 2012 .. 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'); Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366817 Share on other sites More sharing options...
krash11554 Posted August 4, 2012 Author Share Posted August 4, 2012 Pikachu2000 i did what you said and everything works except the css files for the settings page should i just give the whole url for the css files in the head or is there something i do about it differently?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366818 Share on other sites More sharing options...
Pikachu2000 Posted August 4, 2012 Share Posted August 4, 2012 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"> Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366856 Share on other sites More sharing options...
Mahngiel Posted August 4, 2012 Share Posted August 4, 2012 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" /> Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366860 Share on other sites More sharing options...
krash11554 Posted August 4, 2012 Author Share Posted August 4, 2012 Now the when ever i click on a menu that is being included on the settings page its not being found. the link in the adress is http://localhost/garage/edit/index.php? when it should just be http://localhost/garage/index.php?. any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366866 Share on other sites More sharing options...
Mahngiel Posted August 5, 2012 Share Posted August 5, 2012 ... the link in the adress is http://localhost/garage/edit/index.php? when it should just be http://localhost/garage/index.php? Where is that 'edit/' coming from? Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366876 Share on other sites More sharing options...
Pikachu2000 Posted August 5, 2012 Share Posted August 5, 2012 Actually, what shows in the html source of the page? Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366877 Share on other sites More sharing options...
krash11554 Posted August 5, 2012 Author Share Posted August 5, 2012 Mahngiel, the edit hold te settings page Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366879 Share on other sites More sharing options...
krash11554 Posted August 5, 2012 Author Share Posted August 5, 2012 Mahngiel the edit is holding the settings.php file Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366880 Share on other sites More sharing options...
Mahngiel Posted August 5, 2012 Share Posted August 5, 2012 then you're passing the directory reference when you're using the [ic]$_SERVER[ic] SG. Show the code used to generate the links and the var assignments that go with it. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366885 Share on other sites More sharing options...
krash11554 Posted August 5, 2012 Author Share Posted August 5, 2012 the edit is holding the settings.php file Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366886 Share on other sites More sharing options...
krash11554 Posted August 5, 2012 Author Share Posted August 5, 2012 <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 Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366887 Share on other sites More sharing options...
Pikachu2000 Posted August 5, 2012 Share Posted August 5, 2012 The href attribute should hold a complete URL. You were already shown how to do that, so take a shot at it. Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366888 Share on other sites More sharing options...
krash11554 Posted August 5, 2012 Author Share Posted August 5, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/266680-includes/#findComment-1366889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.