boxturt Posted September 23, 2006 Posted September 23, 2006 (edited) I am getting thousands of these errors and I don't know why. >[Fri Sep 22 21:21:23 2006] [error] PHP Warning: main() [<a href='function.include'>function.include</a>]: Failed opening '/usr/local/apache/htdocs/alpha/songs/includes/google_ads.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml on line 141 [Fri Sep 22 21:21:23 2006] [error] PHP Warning: main(/usr/local/apache/htdocs/alpha/songs/includes/google_ads.inc) [<a href='function.main'>function.main</a>]: failed to open stream: No such file or directory in /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml on line 141 The files that are being requested get visibly served. Is it that these files all have an .inc extention. I did try using a different extention and it appears to work but it may be too soon to tell. This has been going on for a little while now ( i forgot about it) but it hasn't always been this way. Any thoughts? Thanks, Ty Edited September 23, 2006 by boxturt Quote
telcor Posted September 23, 2006 Posted September 23, 2006 I am getting thousands of these errors and I don't know why. [Fri Sep 22 21:21:23 2006] [error] PHP Warning: main() [<a href='function.include'>function.include</a>]: Failed opening '/usr/local/apache/htdocs/alpha/songs/includes/google_ads.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml on line 141 Failed opening means one of several things: The file path is incorrect (typo, directory name is upper-cased rather than lower-cased, etc) The file does not exist The permissions on the file prevent PHP from opening it Since changing the file name seemed to work, it can also be an error caused by the web server configuration, wherein it doesn't recognize your file as a PHP file (although that would be rather odd because at this point it's PHP doing the processing, not Apache). Quote
TCH-Andy Posted September 23, 2006 Posted September 23, 2006 Welcome to the forums telcor And thanks for helping out As you say, the path is incorrect. Ty, you are trying to include "/usr/local/apache/htdocs/alpha/songs/includes/google_ads.inc" which is in a location on the server that you don't have access to .... (note the first part of the path). You should be including "/home/mysite/public_html/alpha/songs/includes/google_ads.inc" I suspect (note the beginning part of the path), where "mysite" is of course your username. What is the source code line around line 141 of /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml ? Quote
boxturt Posted September 23, 2006 Author Posted September 23, 2006 (edited) It's 8:15 am here and I haven't had coffee yet......... Thanks for the replies and welcome to the forum telcor. Here is (one of) the lines in question. ><?php include $_SERVER['DOCUMENT_ROOT']."/alpha/songs/includes/google_ads.inc"; ?> Currently the page h*tp://lyricsplayground.com/alpha/songs/g/gutenabendgutenacht.shtml looks fine, shows the ads and has the errors in log only. If I change it to ><?php include "includes/google_ads.inc"; ?> I get no ads and this error on the page: Warning: main(includes/google_ads.inc) [function.main]: failed to open stream: No such file or directory in /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml on line 141 Warning: main() [function.include]: Failed opening 'includes/google_ads.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml on line 141 If I change it to ><?php include "/includes/google_ads.inc"; ?> I get no ads and this on the page: Warning: main() [function.main]: open_basedir restriction in effect. File(/includes/google_ads.inc) is not within the allowed path(s): (/home/mysite/:/usr/local/sqmail/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml on line 141 Warning: main(/includes/google_ads.inc) [function.main]: failed to open stream: Operation not permitted in /home/mysite/public_html/alpha/songs/g/gutenabendgutenacht.shtml on line 141 I could say more but it's still too early Thanks OOPS. Told you it was too early. Andy I tried what you suggested on that one particular page and it seems to work. Now I have to chang it 118,000 more times. There's got to be way........... Edited September 23, 2006 by boxturt Quote
telcor Posted September 23, 2006 Posted September 23, 2006 Welcome to the forums telcor! Thanks for all the welcomes. I've actually been around quite a while, just never created an account until last night. Quote
TCH-Don Posted September 23, 2006 Posted September 23, 2006 Welcome to the forums telcor Thanks for all the help you have been giving. Quote
boxturt Posted September 24, 2006 Author Posted September 24, 2006 (edited) Hmm......... two things........... I can't duplicate the error from my home machine using cable OR dial-up connection (to change IPs) I've visited dozens and dozens of pages and the error log shows nothing. That doesn't seem right? Second - is there any way to shorten ><?php include "/home/mysite/public_html/alpha/songs/includes/google_ads.inc"; ?> Seems I can't do much effective testing... Edited September 24, 2006 by boxturt Quote
telcor Posted September 24, 2006 Posted September 24, 2006 (edited) Second - is there any way to shorten ><?php include "/home/mysite/public_html/alpha/songs/includes/google_ads.inc"; ?> Seems I can't do much effective testing... It depends upon the location of the included file in relation to the file that calls include. For example, if the calling file is: /home/myname/public_html/index.php And the file you want included is: /home/myname/public_html/includes/library/file.php then you can have index.php include file.php like this: >include_once(dirname(__FILE__).'/includes/library/file.php'); Didn't really save on characters though However, depending upon the security settings you can add /home/myname/public_html/includes to your PHP Path. There are at least two ways to accomplish this: within PHP, or using an .htaccess file. Method #1: >$path = ini_get('include_path'); ini_set('include_path', "/home/myname/public_html/includes:$path"); Now you can include any file within the includes directory tree like so: >include_once('library/file.php'); ... include_once('my_file.php'); Method #2: Within an .htaccess file, you can set the PHP Include like this: >php_value include_path ".:/home/myname/public_html/libraries" This gives the same effect as method #1. Now neither of these are guaranteed to work since it depends upon the security settings of your particular webhost. However, the following option will work with most common security settings. Method #3: Create a constant in the main file of your application. The constant resolves to your include path. Note that the constant must be defined in every file that needs it. A simple way to accomplish this is to define the constant in a configuration.php file and include that file in every PHP file. This method also requires altering all require, include, require_once and include_once statement to use the constant. Here is an example: ><?php //The configuration.php file define(MY_PATH, '/home/myname/public_html/includes'); ?> <?php //Another file: test.php include_once('configuration.php'); include_once(MY_PATH.'/libraries/file.php'); ?> Naturally, the proper, full path to configuration.php must be used when it is included. Edited September 24, 2006 by telcor Quote
boxturt Posted September 24, 2006 Author Posted September 24, 2006 Thanks very much. Method 3 is probably the way to go (for flexibility sake) but I don't yet quite understand how to make it work. This is quite a bit for me to digest but I'll give it a try. Quote
telcor Posted September 24, 2006 Posted September 24, 2006 Thanks very much. Method 3 is probably the way to go (for flexibility sake) but I don't yet quite understand how to make it work. This is quite a bit for me to digest but I'll give it a try. Feel free to ask for more help. Quote
boxturt Posted September 25, 2006 Author Posted September 25, 2006 (edited) Thank you. Yeah, I'm lost. I can't figure out how to do this. Once again here is the path: ><?php include('/home/user/public_html/alpha/songs/includes/file1.inc'); ?> There are 3 seperate 'includes' on each page. The tree is basically: /public_html/alpha/songs/a/a_songs.shtml /public_html/alpha/songs/b/b_songs.shtml ...etc.... /public_html/alpha/songs/includes/ ...etc.... /public_html/alpha/songs/y/y_songs.shtml /public_html/alpha/songs/z/z_songs.shtml I really don't want to put the 'user' 3 times per page on 40,000 pages I would be very grateful for any help. Thank you. Hahahahaha - I was wrong - it's only 31,000 pages Edited September 25, 2006 by boxturt Quote
telcor Posted September 25, 2006 Posted September 25, 2006 Thank you. Yeah, I'm lost. I can't figure out how to do this. Once again here is the path: ><?php include('/home/user/public_html/alpha/songs/includes/file1.inc'); ?> There are 3 seperate 'includes' on each page. The tree is basically: /public_html/alpha/songs/a/a_songs.shtml /public_html/alpha/songs/b/b_songs.shtml ...etc.... /public_html/alpha/songs/includes/ ...etc.... /public_html/alpha/songs/y/y_songs.shtml /public_html/alpha/songs/z/z_songs.shtml I really don't want to put the 'user' 3 times per page on 40,000 pages I would be very grateful for any help. Thank you. Hahahahaha - I was wrong - it's only 31,000 pages Wow Are those pages automatically generated by an install script? If so, and you have a proper working backup, it might be easier to modify the installer script to insert your custom path in each file, then reinstall. Otherwise the easiest method might be to download the entire site and use a Programmers editor to do a search replace on each file to put in your custom file path. Which application is this? If it's publically accessible, it might be easier for me to give a better answer by taking a look at it. I don't mean what you have installed on your website, just a pointer to where you found this application. Quote
boxturt Posted September 25, 2006 Author Posted September 25, 2006 No installer, no application. Just a page template with content hand entered, titled, saved and uploaded. I can do a (local) search and replace fairly quickly with criline search + replace, which is what I'll need to do regardless of what code I end up using. Quote
TCH-JimE Posted September 25, 2006 Posted September 25, 2006 Hello Boxturt, Telcor has beaten me to solving this, but I would stick with this: ><?php include $_SERVER['DOCUMENT_ROOT']."/alpha/songs/includes/google_ads.inc"; ?> It means that where ever the document it, it will always pickup that file correctley (Long as that folder is set to a minimum CHMOD of 644) JimE Quote
TCH-Bruce Posted September 25, 2006 Posted September 25, 2006 Jim see post #5, he said that's not working. But this should work: ><?php include "/home/accountname/public_html/alpha/songs/includes/google_ads.inc"; ?> Quote
TCH-Don Posted September 25, 2006 Posted September 25, 2006 If google_ads.inc is the only file you are including you could move it to the public_html folder to shorten the path or if your pages include a header like ><?php // add header include $_SERVER['DOCUMENT_ROOT']."/header.php"; // begin main content ?> You could set a variable to the full path/file name there and then just include the variable include ("$google_ads"); on the pages. Quote
boxturt Posted September 25, 2006 Author Posted September 25, 2006 Thanks everyone. I appreciate your input. I think at this point, and because there are 3 seperate and different includes per page, I will just stick with the longer path that includes the user name. I may, however, move the includes folder closer to the root even though it would still need to contain the user name. Fortunately I have invested in a nice search and replace program for just this occassion. Out of curiosity is >include $_SERVER['DOCUMENT_ROOT']."whatever.php"; not valid because of the shared hosting environment. I honestly thought it was the right way to do it. Quote
TCH-Don Posted September 25, 2006 Posted September 25, 2006 oop! thats should be >include $_SERVER['DOCUMENT_ROOT']."/whatever.php"; I corrected my last post. Quote
abinidi Posted September 25, 2006 Posted September 25, 2006 Not that I'm adding to this discussion in any way, but as I was reading through this thread, I thought to myself, "Wow. Another reason why I love being a TCH customer." This forum is great!!! YOU are all what makes it great! Quote
TCH-JimE Posted September 26, 2006 Posted September 26, 2006 Hello, Whilst the method I suggest is working but causing errors (post 5 as Bruce points out), it should not be causing any errors. However, the only difference I can see is that in my lines I use on my own website with the same coding, I don't use files.inc , I use files.php Boxturt, could you try, just on one page, including it as a php file (remember to save it as a php file) and see if the log still sees an error and if so, what that error is. Jim Quote
boxturt Posted September 26, 2006 Author Posted September 26, 2006 (edited) I know I said errors but it's really warnings. In other words the includes gets processed but with warnings in the logs. Oddly enough when I go to a page to try and "track" the warning in the logs it never appears so I'm not sure I can try the experiment you suggest. I'll try it though I've already made all the changes to the files. I can always redo them. (only took an hour to change all 31,000 pages) I did recently read that the .inc extension should be used for libraries but it isn't reserved. a few minutes later....... Nope, I can't tell from looking at (error) log. The experiment page is h_tp://lyricsplayground.com/alpha/new_songs/z/zabadak.shtml in case someone cares to try it and I can see if it shows up. Thanks All Edited September 26, 2006 by boxturt Quote
boxturt Posted September 26, 2006 Author Posted September 26, 2006 Not that I'm adding to this discussion in any way, but as I was reading through this thread, I thought to myself, "Wow. Another reason why I love being a TCH customer." This forum is great!!! YOU are all what makes it great! You are absolutely right Paul. Always a great experience and I always learn something. Quote
boxturt Posted September 27, 2006 Author Posted September 27, 2006 Well, I used the long version on all 31,000 X3 changes and it works fine. I have gone from about 350 error / warnings per hour to about 20 or so per hour. Most of those are people on fishing expeditions. If I get ambitious I may try a few other methods but for now all is well in the kingdom Thanks again for all your input, I appreciate it very much. Quote
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.