Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,360 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