flunn Posted November 21, 2007 Share Posted November 21, 2007 I'm having a problem with "php require()" paths. This is what happens: I have a php file ("FileA") in a directory ("DirectoryA"). This file uses "require()" to access a header ("Header"), which itself is linked to a css style sheet and a graphic. This works fine as long as everything is in the same directory, but when (after changing the "require()" call) I put FileA into a sub-directory of DirectoryA ("DirectoryA1"), there's a problem: the header is accessed, but the css file and the graphic are not. When FileA is in DirectoryA1, the "require()" call is written as follows require('../Header.html') I've experimented with other ways of describing the path and even tried to use an absolute path, but the results are always the same. I've also done some googling but could find nothing useful. Any help with this will be much appreciated. regards to all Quote Link to comment Share on other sites More sharing options...
Glyde Posted November 21, 2007 Share Posted November 21, 2007 Seems like more of an HTML than a PHP problem to me. I think you need to modify your CSS and IMG tags in your HTML to reflect the change in directory. Quote Link to comment Share on other sites More sharing options...
flunn Posted November 21, 2007 Author Share Posted November 21, 2007 Thanks, Glyde, for your reply. But: I'm not sure what you mean by 'modifying tags. Are there different sorts of "img" tags? (And, if so, how would I figure out which one I need here?) Also, I had no idea there was such a thing as a "css tag." I thought that ''css" was just used as an "extension" at the end of a file name. Also, if this were a html problem, I don't see why everything would work fine when all the files were in the same directory, but not when they're in different directories. Quote Link to comment Share on other sites More sharing options...
premiso Posted November 21, 2007 Share Posted November 21, 2007 Are you using relative or absolute paths for the css inside the HTML? Use absolute or even add <base href="http://www.somesite.com/directoryA/style.css"> Especially for headers this is important as different locations of the php files will throw it off, especially if the php file is being included. Quote Link to comment Share on other sites More sharing options...
flunn Posted November 22, 2007 Author Share Posted November 22, 2007 Thank you, premiso, for your reply. Basically your solution works fine. When I used absolute paths in the header the css style sheet and the graphic were accessed properly. There's still a serious problem however: there's a "Flash" sound file linked to the page but now that I've moved that page into another directory, I can't access the Flash player. The Java code that sets this up is as follows: <script type="text/javascript"> var s3 = new SWFObject("mp3player.swf", "line", "100", "20","7"); s3.addVariable("file","<?php print $listen; ?>"); s3.addVariable("repeat","false"); s3.addVariable("showdigits","true"); s3.write("flashbanner"); </script> I tried replacing "mp3player.swf" with an absolute url but that didn't help. ("mp3player.swf" is in the same directory as the file I'm working with was originally in.) best regards and thanks again for your help. Quote Link to comment 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.