include function gives me an error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cgull
Forum Newbie
Posts: 7
Joined: Wed Apr 09, 2008 6:11 am

include function gives me an error

Post by Cgull »

Hello,

I get an error when I'm trying to include a page in my index.php.
My index.php is in:

c:\wamp\www\sigalzcv\xhtml\

The page I'm calling is:

c:\wamp\www\sigalzcv\xhtml\content\work.inc.php

In my index.php I have this code:

<div id="main">
<?php
if (!isset($_REQUEST['content']))
$nextPage = "content/main.inc.php";
else
$nexPage = "content/" . $_REQUEST['content'] . ".inc.php";

include($nextPage);
?>
</div>

When I browse the site, the main page is coming up with no problem, but when I click the button that calls the work.inc.php page, I get this error:

Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\sigalzcv\xhtml\index.php on line 24

I checked with echo and the page does get the word "work" as a content.

I also tried to hardcode the path and wrote: include("content/work.inc.php") and got the same error.

Then I tried hardcoding with: "content/main.inc.php" and still got the error.

Any ideas what is wrong?

Thanks,

Cgull
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: include function gives me an error

Post by aceconcepts »

You're using forward slashes
Post Reply