user3232801 user3232801 - 2 years ago 48
PHP Question

Why am I getting this parse error?

I am the one who knocks

Ibu, Jonathon Reinhart, meda, p.s.w.g, nickhar

Answer Source

You might want to reconsider the way you're doing this (see edit) but in the mean time, I suspect the following is the problem:

!isset($_POST['company']) || empty($_POST['company'])
!isset($_POST['budget']) || empty($_POST['budget'])

Add || after.

!isset($_POST['company']) || empty($_POST['company']) ||
!isset($_POST['budget']) || empty($_POST['budget']) ||

Your other error is coming from:

 $body = "From: " . $_POST['name'] . "\n E-Mail: " . $_POST['email'] . "\n Company: " . $_POST['company'] . "\n Monthly Budget: " . $_POST['budget'] . "\n Message: " . $_POST['message'] "" //<-- These are no good.

Those quotes at the end are not good, get rid of them.

$body = "From: " . $_POST['name'] . "\n E-Mail: " . $_POST['email'] . "\n Company: " . $_POST['company'] . "\n Monthly Budget: " . $_POST['budget'] . "\n Message: " . $_POST['message'];

Edit: In many cases (note I said many, not most, not all), isset() and empty() do not need to be used in conjunction. isset() checks if the value is set to anything, including 0 and ''. empty() will check if it is set and if it is, will see if it is what most people would consider an "empty" value, such as null, '', 0, and others.

So, I tend to just use !empty() or isset() which are sufficient on their own.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download