Fudgey Posted June 17, 2009 Share Posted June 17, 2009 I'm quite new at php, but it seems lovely. however, i cant seem to get the include() right. i continually get this message: PHP Warning: include(/menu/menu.php) [function.include]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\index.php on line 22 PHP Warning: include() [function.include]: Failed opening '/menu/menu.php' for inclusion (include_path='c:\php\includes') in C:\Inetpub\wwwroot\index.php on line 22 and the code for index.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="1280" height="444" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="231" colspan="2" background="/CSA Title.jpg"></td> </tr> <tr> <td width="254" background="/CSA Nav.jpg"><table width="248" height="246" border="0"> <tr> <td width="34" height="23"> </td> <td width="183"> </td> <td width="17"> </td> </tr> <tr> <td height="136"> </td> <td><?php include("/menu/menu.html"); ?></td> <td> </td> </tr> <tr> <td height="67"> </td> <td> </td> <td> </td> </tr> </table></td> <td width="1026"> </td> </tr> </table> </body> </html> I use php5 with IIS in windows XP. I have checked that the files are in all the right places, and i believe IIS has been configured correctly. Any help would be very much appreciated, i've been struggling with this all morning. Thanks ERIK EDITED BY akitchin: as mentioned, please use code tags for code in all future posts. Quote Link to comment https://forums.phpfreaks.com/topic/162542-solved-include-not-working/ Share on other sites More sharing options...
Yesideez Posted June 17, 2009 Share Posted June 17, 2009 First, if you surround your code with [code] and [/code] tags it makes things stand out and preserves formatting. Next, try removing the first / from the include and try again. Make sure the "menu" folder is relative to where the script is being run and menu.html is actually inside it. Quote Link to comment https://forums.phpfreaks.com/topic/162542-solved-include-not-working/#findComment-857849 Share on other sites More sharing options...
Fudgey Posted June 17, 2009 Author Share Posted June 17, 2009 Thanks for the reply. I have already tried using a relative path, no cigar. In any case, i would like to keep the path absolute as i will have quite a few pages sorted into folders. thanks ERIK Quote Link to comment https://forums.phpfreaks.com/topic/162542-solved-include-not-working/#findComment-858042 Share on other sites More sharing options...
Maq Posted June 17, 2009 Share Posted June 17, 2009 Can you please CnP the hard coded path to "menu.php" and "index.php". Quote Link to comment https://forums.phpfreaks.com/topic/162542-solved-include-not-working/#findComment-858043 Share on other sites More sharing options...
PFMaBiSmAd Posted June 17, 2009 Share Posted June 17, 2009 A leading slash / on a file system path refers to the root of the current hard disk. So, yes, that is an absolute path, but it is not a path to where your file likely is. You need to use $_SERVER['DOCUMENT_ROOT'] with your path/file to form an absolute file system path that refers to where your file is. Quote Link to comment https://forums.phpfreaks.com/topic/162542-solved-include-not-working/#findComment-858047 Share on other sites More sharing options...
Fudgey Posted June 17, 2009 Author Share Posted June 17, 2009 Thanks, that seems to do the trick. ERIK Quote Link to comment https://forums.phpfreaks.com/topic/162542-solved-include-not-working/#findComment-858328 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.