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 trialPaul M
16,370 PointsPHP Error
I received this message
Warning: require(inc/phpmailer/class.phpmailer.php): failed to open stream: No such file or directory in /home/treehouse/workspace/suggest.php on line 17
Fatal error: require(): Failed opening required 'inc/phpmailer/class.phpmailer.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/treehouse/workspace/suggest.php on line 17
Does anyone know how to fix it?
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim(filter_input(INPUT_POST,"name",FILTER_SANITIZE_STRING));
$email = trim(filter_input(INPUT_POST,"email",FILTER_SANITIZE_EMAIL));
$details = trim(filter_input(INPUT_POST,"details",FILTER_SANITIZE_SPECIAL_CHARS));
if (trim($name) == "" || $email == "" || $details == "") {
echo "Please fill out the required fields: Name, Email, Details";
exit;
}
if ($_POST["address"] != "") {
echo "Bad form input";
exit;
}
require("inc/phpmailer/class.phpmailer.php");
$mail = new PHPMailer;
if (!$mail->ValidateAdress($email)) {
echo "Invalid Email Address";
exit;
}
5 Answers
Luke Pettway
16,593 PointsMake sure the file path is correct, whenever you get that issue, it means the file isn't found.
"failed to open stream: No such file or directory in ... on line 17"
Kevin Korte
28,149 PointsYep, as Luke said, check your path. It's not able to find your file you are requiring at "inc/phpmailer/class.phpmailer.php"
yasir amin
155 PointsThis issue because namespace. In class.phpmailer.php file remove namespace line
Jaime Rios
Courses Plus Student 21,100 PointsFor me it worked when i wrote validateAddress instead of .ValidateAddress
Akash yadav
10,046 PointsHere is your code:
if (!$mail->ValidateAdress($email)) { echo "Invalid Email Address"; exit; }
No, one noticed down one simple error, i.e check the spelling of Address in ValidateAddress. you have surely missed an alphabet "d".