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 Build a Simple PHP Application Wrapping Up The Project Using A Third-Party Library

Philip Yiu Fai Leung
Philip Yiu Fai Leung
1,808 Points

I have received error message with my code, what is wrong ?

Warning: require_once(inc/phpmailer/class.phpmailer.php): failed to open stream: No such file or directory in C:\xampp\htdocs\contact.php on line 26

Fatal error: require_once(): Failed opening required 'inc/phpmailer/class.phpmailer.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\contact.php on line 26

require_once("inc/phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); if(!$mail->ValidateAddress($email)){ echo"You must specify a valid email address."; exit; }

3 Answers

Hi Philip,

It looks like there may be an issue with the path. In your htdocs directory, do you also have an inc folder? Does the inc folder contain a phpmailer folder, and does this contain the class.phpmailer.php?

contact.php is referencing that using a relative path, so inc should be in the same folder as contact.php.

Philip Yiu Fai Leung
Philip Yiu Fai Leung
1,808 Points

Hi Robert,

I don't have an inc folder, let me try to create one and see.

Thanks !

in this case I think the error is pretty self explanatory.. are you doing this on your local pc or workspaces?

Philip Yiu Fai Leung
Philip Yiu Fai Leung
1,808 Points

Hi Robert,

I got it, it is done,

Many thanks !

Philip

Awesome!