Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/162542-solved-include-not-working/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.