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 Build a Simple PHP Application Adding a Contact Form Working with Get Variables

Kirran Iveson
Kirran Iveson
2,191 Points

Error message I can't seem to fix

I keep getting: Fatal error: Function name must be a string in C:\xampp\htdocs\contact.php on line 34

Line 34 is this:

 <?php if (isset($_GET["status"]) AND $_GET("status") == "thanks") { ?>

Any thoughts?

Fixed markdown for the posted code. If you're curious about how to add markdown like this on your own, checkout this thread on posting code to the forum . Also, there is a link at the bottom called Markdown Cheatsheet that gives a brief overview of how to add markdown to your posts.

While you had the 3 backticks for a code block, there needs to be a blank line preceding these backticks.

2 Answers

Hi Kirran,

AND $_GET("status") is treating $_GET like a function because of the parentheses.

<?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>

Edit: the second call to _GET was using parentheses instead of square brackets. Line corrected above.

AND is not valid syntax.. use &&

Kirran Iveson
Kirran Iveson
2,191 Points

I tried switching it and nothing changes. If it is invalid they probably shouldn't put it in the video, although I've seen a few others just say that they are interchangeable (perhaps with subtle differences that new coders don't know about yet!).

AND is valid, it's just a lower precedence operator than &&.