# Problem with php code. Please help!

**URL:** <https://forum.kirupa.com/t/problem-with-php-code-please-help/189280>\
**Category:** programming\
**Created:** [June 1, 2006, 12:06pm UTC](https://forum.kirupa.com/t/problem-with-php-code-please-help/189280 "2006-06-01T12:06:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spindrift](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@spindrift](https://forum.kirupa.com/u/spindrift)\
**Post date:** [June 1, 2006, 12:06pm UTC](https://forum.kirupa.com/t/problem-with-php-code-please-help/189280/1 "2006-06-01T12:06:50Z")

</div>

Hello!

I’m using the following syntax to bring content into my websites’ layout template:

```auto
<?php //check in the root folder first
if(file_exists('./' . $pagename . '.php'))
{
    include './' . $pagename . '.php';
}
//if it wasn't found in the root folder then check in the news folder
elseif(file_exisits('./news/' . $filename . '.php'))
{
    include './news/' . $pagename . '.php';
}
// if it couldn't be found display message
else
{
    echo $pagename . '.php could not be found in either the root folder or the news folder!';
} ?>

```

What it’s essentially saying is, if you can’t find the .php file in the \_root folder, look for it in the /news/ folder.

It works perfectly if loading something from the \_root folder but I get an error if I need to bring something from the /news/ folder.

Can anyone see any potential problems with my code?

Thank you very much and I hope to hear from you.

Take care,

Mark
