Php Warnings With Includes

liunx

Guest
Pages and pages of the same error happening on 100's of different pages<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->[Fri Oct  7 19:57:16 2005] [error] PHP Warning:  main(): 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/lyricsp/public_html/alpha/songs/k/knots.shtml on line 76<br />[Fri Oct  7 19:57:16 2005] [error] PHP Warning:  main(/usr/local/apache/htdocs/alpha/songs/includes/google_ads.inc): failed to open stream: No such file or directory in /home/lyricsp/public_html/alpha/songs/k/knots.shtml on line 76<!--c2--></div><!--ec2--><br /><br />I'm using regular php includes which has been working fine for months and months<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php <br />include $_SERVER['DOCUMENT_ROOT']."/alpha/songs/includes/google_ads.inc"; <br />?><!--c2--></div><!--ec2--><br /><br />The files do exist, and they do display with the page. To me the error message itself looks odd, mostly the paths mentioned.<br /><br />I think I've been staring at it too long. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sleepy.gif" style="vertical-align:middle" emoid=":sleepy:" border="0" alt="sleepy.gif" /> <br />Any thoughts are always greatly appreciated.<br /><br />Thanks!<!--content-->
But wait - there's <i>more!!</i> <br /><br />Ok, I did some more thinking and it looks like all my content (almost 30,000 pages) is getting indexed by Google (at least) <b>two</b> ways. The first listing reads "Supplemental Result" and is listed by ip/~user/........ followed by a regular listing.<br /><br />Try both of these and you'll see...<br /><br />207.44.240.63/~lyricsp/alpha/songs/g/greenwoodcreek.shtml<br /><br />lyricsplayground.com/alpha/songs/g/greenwoodcreek.shtml<br /><br />It's the first one causing errors. Why?? And why is it even listed there??<br /><br />Anyway - do I need to put some sort of redirect in .htaccess? Is that even the thing to do and how?<br /><br />Thanks again.<!--content-->
Hi Boxturt,<br /><br />It's because you are including the file by reference - the clue is in the error <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Failed opening '/usr/local/apache/htdocs/alpha/songs/includes/google_ads.inc' for inclusion<!--c2--></div><!--ec2--> which it not looking for the include in your file space.<br /><br />Try something like <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteEngine On<br />RewriteCond %{HTTP_HOST} !^lyricsplayground.com$ [NC]<br />RewriteRule ^(.*)$ http://lyricsplayground.com/$1 [R,L]<!--c2--></div><!--ec2--><br /><br />in your .htaccess - please note, that this does depend on if you have subdomains / other redirects in your .htaccess.<!--content-->
It works!! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Thank you, thank you.<br /><br />I first put it in the htaccess file in the songs directory and got a 404 error. Then I put added it to the root htaccess file and victory was ours!<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->It's because you are including the file by reference - the clue is in the error<!--QuoteEnd--></div><!--QuoteEEnd--> <br /><br />I'm lost here. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Could you tell me how else to should/could include this? (for future reference)<br /><br />Thanks kindly Andy.<!--content-->
Hi Boxturt,<br /><br />I'm glad it's all sorted now <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <br /><br />Now you have that in your .htaccess it should be fine about everything in the future - apart from if you use subdomains. <br /><br />Basically some scripts do not like to run without the domain name, often because of "includes", as in your case, where it interprets the include to reference an invalid path. There are some alternative workrounds - but they virtually all have problems of some sort or another. Unless anyone else knows of a failsafe system.<!--content-->
I know - if it's not one thing it's another <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/dry.gif" style="vertical-align:middle" emoid="<_<" border="0" alt="dry.gif" /> <br /><br />Thanks again <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
 
Top