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

Irma Millirons
Irma Millirons
9,711 Points

Using the same code on video for require_once function but keep getting a syntax error on a line that has no code.

require_once("inc/phpmailer/class.phpmailer.php"); {
            $mail = new PHPMailer();

        if (!$mail->ValidateAddress($email)){
            echo "You must specify an email address.";
            exit;

}

4 Answers

Alex Heil
Alex Heil
53,547 Points

hey Irma Millirons , can you paste the whole code of the php file in here so that we can have a look? in general when the error points you to a line that has no code in it (or it's the end of the file) then moving backwards from that point helps tracking it down a lot. usually it's something like a missed semicolon or bracket that causes this and the interpreter simply recognizes this error at the end of the code block.

Irma Millirons
Irma Millirons
9,711 Points

When I put that code in the page breaks and shows a code error.I don't why.

Alex Heil
Alex Heil
53,547 Points

at the end of the first line you have a } (after the require_once), try to remove this one. if this doesn't fix the problem please do the following:

1) copy the whole content of the file and paste it into this forum so that we can look at it. 2) please also add the exact error message you receive so we can trace it down.

Maybe the extra curly braces surrounding the block of "mail" code is causing the problem?

require_once("inc/phpmailer/class.phpmailer.php"); { ///this? $mail = new PHPMailer();

    if (!$mail->ValidateAddress($email)){
        echo "You must specify an email address.";
        exit;

}

Irma Millirons
Irma Millirons
9,711 Points

Thanks guys! It worked.