I have some php code. In the code I put links im using it so that when I update the links on my website it does it on all pages. The code works fine untill I place it in a folder other than the root directory. The error I get is: Warning: main(affiliates.php) [function.main]: failed to open stream: No such file or directory in /home/pecli/public_html/gaming/PS3.php on line 216 Warning: main(affiliates.php) [function.main]: failed to open stream: No such file or directory in /home/pecli/public_html/gaming/PS3.php on line 216 Warning: main(affiliates.php) [function.main]: failed to open stream: No such file or directory in /home/pecli/public_html/gaming/PS3.php on line 216 Warning: main() [function.include]: Failed opening 'affiliates.php' for inclusion (include_path='.:/usr/php4/lib/php:/usr/local/php4/lib/php') in /home/pecli/public_html/gaming/PS3.php on line 216 Code (markup): The PHP code is: <div id="cont"> <ul> <li> <a href="#" onClick="MyWindow=window.open('http://www.xninelivesx.com/wowgold.htm','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=230,height=108'); return false;">WOW Gold</a> - <i>5% Off</i></li> </ul> <p><i> Online Flash Games</i></p> <ul> <li><a href="http://games.itarea.org">Jocuri flash</a></li> <li><a href="http://www.ejocuri.us">Jocuri barbie</a></li> <li><a href="http://www.24play.org">Jocuri gratuite</a></li> <li><a href="http://www.e-jocuri.us">Jocuri online</a> </li> </ul> </div> Code (markup): The code to link the php file: <?php include("affiliates.php");?> Code (markup): How can I fix this problem? I tryed putting the full path to the php file and it still didnt work.
There is no line 216 The affiliates.php code is: <div id="cont"> <ul> <li> <a href="#" onClick="MyWindow=window.open('http://www.xninelivesx.com/wowgold.htm','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=230,height=108'); return false;">WOW Gold</a> - <i>5% Off</i></li> </ul> <p><i> Online Flash Games</i></p> <ul> <li><a href="http://games.itarea.org">Jocuri flash</a></li> <li><a href="http://www.ejocuri.us">Jocuri barbie</a></li> <li><a href="http://www.24play.org">Jocuri gratuite</a></li> <li><a href="http://www.e-jocuri.us">Jocuri online</a> </li> </ul> </div> Code (markup): Although the page im using it on is not specified. I also want it an all of my webpages in different folders.
<?php include("/folder/affiliates.php");?> Code (markup): Does that help, im am no expert and i'm not sure I understand your problem properly.
Php is telling you that that file can't be found. I believe that there's something wrong with your path... or maybe the file doesn't exist. You should check that.
This is still not working, the affiliates.php is in the root directory. And I want the code to be linked inside a php file named PS3.php The PS3.php is in a different folder called 'gaming' not the root directory
hmm try with whole url http://yoursite.com/affiliates.php <?php include('folder/affiliates.php'); ?> PHP:
I already tried that but thanks. Is there any reason it works with all files in the main directory but doesnt work with any file in a different folder? Is it because im linking to a different folder and you cant do that?
Put this in PS3.php: <?php echo dirname(__FILE__); ?> PHP: Then in affiliates.php: <?php include( "whatever_the_above_says/PS3.php" ); ?> PHP: Hard-coded include path indeed, but it's the easiest if you can't get things like this working.
I would try this other <?php include "http://".$_SERVER['HTTP_HOST']."/folder/affiliates.php;" ?> Code (markup): $_SERVER['HTTP_HOST']; will always return your full URL address
well ya i mean if it's - affiliates.php --ps3.php you'd need to change it to <?php include ("../affiliates.php");?> when you call the file from ps3.php.