Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics PHP on the Web What's Next?

Cant pass the previous question, preview said 'cant find favorites.php'

is there an error?

Justin Behnke
Justin Behnke
4,326 Points

I stop going by the result of the "TEST" and go only by the result of the preview. If it previews correctly you did good and move on... some of those just aren't working.

7 Answers

The instructions state that the favorites.php file is in the current directory. For files in the current directory you simply include the file name [<?php include 'favorites.php';?>] instead of the previous example that were in the "inc" directory [<?php include 'inc/favorites.php';?>].

David Grimm
David Grimm
12,532 Points

Exactly the same happened to me, but then I noticed I've forgotten semi-colon at the end of the statement.

The preview seemed OK, but evaluation wouldn't let you through. After adding semi-colon, it was OK.

The evaluation is quite rigid, but I don't think that one should just give up on it, just because you migh think you have it right according to the Preview :)

nico dev
nico dev
20,364 Points

That's the right attitude! Cheers!!

please post your code here, so that we can see what you are doing wrong. As Leonardo and Daniel said, since the 'favorites.php' file is in the same directory, you just have to include it by adding the following code to your current file: <?php include('favorites.php'); ?>. This code should be placed below the heading <h1></h1> tag.

some of these php code challenges are broken. I just tested this one and even when I can see the preview with the included file, it still says its not included when I click check work. I've noticed several of these types of issues with the php code challenges.

A lot of these php challenges are very fidgety even though

<?php INCLUDE 'favorites.php'?>

Will in fact output the correct code in the output.

However,

<?php INCLUDE 'favorites.php';?>

is the answer they are looking for under the <h1></h1> tag. Note the subtle difference of the semicolon ';' after the php statement.

Kat Cuccia
Kat Cuccia
786 Points

If you didn't put a semicolon after the include function, it won't pass you, even though you can see the file in the preview

Leonardo Da Costa
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Leonardo Da Costa
Front End Web Development Techdegree Graduate 14,559 Points

Below the <h1> tag:

<?php include 'favorites.php'; ?> // since its in the same directory, you can just insert the php file

Is that what you put ? I hope I could help, good luck.

you need to enter your code in between the <h1> </h1> tag your code should be like <?php include 'favorites.php '; ?> it should come correct

<?php include 'favorites.php';?> afther the heading tag "<h1></h1>" Good luck