I'm getting this error code on my website when trying to submit the new form I've uploaded.
Parse error: syntax error, unexpected '!' in /www/zymichost.com/m/y/c/mycustombuiltpc/htdocs/CustomForm.php on line 31
Line 31 is !isset($_POST['Role']) ||
23 2774
Can you give more code ... that looks just like a part of some if statement ... or is it?
Hi, it's from this section of the PHP -
// validation expected data exists
-
if(!isset($_POST['first_name']) ||
-
!isset($_POST['last_name']) ||
-
!isset($_POST['email']) ||
-
!isset($_POST['comments'])
-
!isset($_POST['Role']) ||
-
!isset($_POST['RAM']) ||
-
!isset($_POST['RAID']) ||
-
!isset($_POST['HDD1']) ||
-
!isset($_POST['HDD2']) ||
-
!isset($_POST['OS']) ||
-
!isset($_POST['Extras']) ||
-
!isset($_POST['Accessories']) ||
-
!isset($_POST['Guarantee']) ||
-
!isset($_POST['customer']) ||
-
!isset($_POST['budget'])) {
-
died('We are sorry, but there appears to be a problem with the form you submitted.');
-
!isset($_POST['comments'])
-
should probably be -
!isset($_POST['comments']) ||
-
Ok, thanks for the help, I'll try it asap
This is the current code. When the form is submitted i get the defined error message (from this code) on screen. Any suggestions as to how to fix this? -
-
// validation expected data exists
-
if(!isset($_POST['first_name']) ||
-
!isset($_POST['last_name']) ||
-
!isset($_POST['email']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments']) ||
-
!isset($_POST['comments'])) {
-
died('We are sorry, but there appears to be a problem with the form you submitted.');
-
}
-
-
$first_name = $_POST['first_name']; // required
-
$last_name = $_POST['last_name']; // required
-
$email_from = $_POST['email']; // required
-
$Role = $_POST['comment'];
-
$RAM = $_POST['comment'];
-
$RAID = $_POST['comment'];
-
$HDD1 = $_POST['comment'];
-
$HDD2 = $_POST['comment'];
-
$OS = $_POST['comment'];
-
$GPU = $_POST['comment'];
-
$Extras = $_POST['comment'];
-
$Accessories = $_POST['comment'];
-
$Guarantee = $_POST['comment'];
-
$customer = $_POST['comment'];
-
$budget = $_POST['comment'];
-
-
$error_message = "";
-
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
-
if(!preg_match($email_exp,$email_from)) {
-
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
-
}
-
$string_exp = "/^[A-Za-z .'-]+$/";
-
if(!preg_match($string_exp,$first_name)) {
-
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
-
}
-
if(!preg_match($string_exp,$last_name)) {
-
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
-
}
-
if(strlen($Role) < 2) {
-
$error_message .= 'The Role you entered do not appear to be valid.<br />';
-
}
-
if(strlen($RAM) < 2) {
-
$error_message .= 'The RAM you entered do not appear to be valid.<br />';
-
}
-
if(strlen($RAID) < 2) {
-
$error_message .= 'The RAID you entered do not appear to be valid.<br />';
-
}
-
if(strlen($HDD1) < 2) {
-
$error_message .= 'The HHD1 you entered do not appear to be valid.<br />';
-
}
-
if(strlen($HDD2) < 2) {
-
$error_message .= 'The HDD2 you entered do not appear to be valid.<br />';
-
}
-
if(strlen($OS) < 2) {
-
$error_message .= 'The OS you entered do not appear to be valid.<br />';
-
}
-
if(strlen($GPU) < 2) {
-
$error_message .= 'The GPU you entered do not appear to be valid.<br />';
-
}
-
if(strlen($Extras) < 2) {
-
$error_message .= 'The Extras you entered do not appear to be valid.<br />';
-
}
-
if(strlen($Accessories) < 2) {
-
$error_message .= 'The Accessories you entered do not appear to be valid.<br />';
-
}
-
if(strlen($Guarantee) < 2) {
-
$error_message .= 'The Guarantee you entered do not appear to be valid.<br />';
-
}
-
if(strlen($customer) < 2) {
-
$error_message .= 'The customer you entered do not appear to be valid.<br />';
-
}
-
if(strlen($budget) < 2) {
-
$error_message .= 'The budget you entered do not appear to be valid.<br />';
-
}
-
if(strlen($error_message) > 0) {
-
died($error_message);
-
}
-
$email_message = "Form details below.\n\n";
-
-
function clean_string($string) {
-
$bad = array("content-type","bcc:","to:","cc:","href");
-
return str_replace($bad,"",$string);
-
}
-
-
$email_message .= "First Name: ".clean_string($first_name)."\n";
-
$email_message .= "Last Name: ".clean_string($last_name)."\n";
-
$email_message .= "Email: ".clean_string($email_from)."\n";
-
$email_message .= "Role: ".clean_string($comments)."\n";
-
$email_message .= "RAM: ".clean_string($comments)."\n";
-
$email_message .= "RAID: ".clean_string($comments)."\n";
-
$email_message .= "HDD1: ".clean_string($comments)."\n";
-
$email_message .= "HDD2: ".clean_string($comments)."\n";
-
$email_message .= "OS: ".clean_string($comments)."\n";
-
$email_message .= "GPU: ".clean_string($comments)."\n";
-
$email_message .= "Extras: ".clean_string($comments)."\n";
-
$email_message .= "Accessories: ".clean_string($comments)."\n";
-
$email_message .= "Guarantee: ".clean_string($comments)."\n";
-
$email_message .= "customer: ".clean_string($comments)."\n";
-
$email_message .= "budget: ".clean_string($comments)."\n";
Hi, I've removed that line of code but problem is still there. Think there is an issue with this - function die($error) {
-
// your error code can go here
-
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
-
echo "These errors appear below.<br /><br />";
-
echo $error."<br /><br />";
-
echo "Please go back and fix these errors.<br /><br />";
-
die();
as this is the error message always being displayed.
Is your field called comments or comment? You use both and one of them is wrong.
Thanks, that seems to have helped. The form now submits! However when it appears in my email, its only displaying the last value (the budget) that was entered.
This is the form how it appears in my inbox: -
First Name: Test
-
Last Name: Customer
-
Email: email@email.com
-
Role: 400
-
RAM: 400
-
RAID: 400
-
HDD1: 400
-
HDD2: 400
-
OS: 400
-
GPU: 400
-
Extras: 400
-
Accessories: 400
-
Guarantee:
-
Customer: 400
-
Budget: 400
Is there anything that needs to be changed in the PHP. I think this is the part of code that needs to be changed: - $email_message = "Form details below.\n\n";
-
-
function clean_string($string) {
-
$bad = array("content-type","bcc:","to:","cc:","href");
-
return str_replace($bad,"",$string);
-
}
-
-
$email_message .= "First Name: ".clean_string($first_name)."\n";
-
$email_message .= "Last Name: ".clean_string($last_name)."\n";
-
$email_message .= "Email: ".clean_string($email_from)."\n";
-
$email_message .= "Role: ".clean_string($Role)."\n";
-
$email_message .= "RAM: ".clean_string($RAID)."\n";
-
$email_message .= "RAID: ".clean_string($RAID)."\n";
-
$email_message .= "HDD1: ".clean_string($HDD1)."\n";
-
$email_message .= "HDD2: ".clean_string($HDD2)."\n";
-
$email_message .= "OS: ".clean_string($OS)."\n";
-
$email_message .= "GPU: ".clean_string($GPU)."\n";
-
$email_message .= "Extras: ".clean_string($Extras)."\n";
-
$email_message .= "Accessories: ".clean_string($Accessories)."\n";
-
$email_message .= "Guarantee: ".clean_string($guarantee)."\n";
-
$email_message .= "Customer: ".clean_string($customer)."\n";
-
$email_message .= "Budget: ".clean_string($budget)."\n";
-
You assigned same value to all of them: -
$Role = $_POST['comment'];
-
$RAM = $_POST['comment'];
-
$RAID = $_POST['comment'];
-
$HDD1 = $_POST['comment'];
-
$HDD2 = $_POST['comment'];
-
$OS = $_POST['comment'];
-
$GPU = $_POST['comment'];
-
$Extras = $_POST['comment'];
-
$Accessories = $_POST['comment'];
-
$Guarantee = $_POST['comment'];
-
$customer = $_POST['comment'];
-
$budget = $_POST['comment'];
-
I've changed them to - $first_name = $_POST['first_name']; // required
-
$last_name = $_POST['last_name']; // required
-
$email_from = $_POST['email']; // required
-
$Role = $_POST['comments'];
-
$RAM = $_POST['comments1'];
-
$RAID = $_POST['comments2'];
-
$HDD1 = $_POST['comments3'];
-
$HDD2 = $_POST['comments4'];
-
$OS = $_POST['comments5'];
-
$GPU = $_POST['comments6'];
-
$Extras = $_POST['comments7'];
-
$Accessories = $_POST['comments8'];
-
$Guarantee = $_POST['comments9'];
-
$customer = $_POST['comments10'];
-
$budget = $_POST['comments11'];
-
but I'm again recieving the error messages that I was before.
Do you need different values depending on what, for example, budget, says.
Role, RAM, RAID, HDD1, HDD2, OS, GPU and Guarantee are drop down menus. Extras and Accessories are tick boxes. customer and budget are text boxes.
Currently all of the error messages for the above words are like this: - if(strlen($Role) < 2) {
-
$error_message .= 'The Role you entered do not appear to be valid.<br />';
-
On the HTML form - <input type="textbox" name="bob" />
On the PHP page
They need to match.
All matching now, but the site is giving a new Parse Error message. This time it's
'Parse error: syntax error, unexpected T_STRING in /www/zymichost.com/m/y/c/mycustombuiltpc/htdocs/CustomForm.php on line 48'
when Line 48 is - $Memory Size = $_POST['ram'];
You have a space in your variable name.
All spaces removed. Now getting this Error coding on the site: We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.
The RAID you entered do not appear to be valid.
The Extras you entered do not appear to be valid.
The Accessories you entered do not appear to be valid.
The Customer Specifics you entered do not appear to be valid.
The Maximum Budget you entered do not appear to be valid.
Please go back and fix these errors.
The respective coding for each of the above are: - !isset($_POST['raid']) ||
-
-
$RAID = $_POST['raid'];
-
-
if(strlen($RAID) < 2) {
-
$error_message .= 'The RAID you entered do not appear to be valid.<br />';
-
}
-
-
$email_message .= "RAID: ".clean_string($raid)."\n";
-
- !isset($_POST['extras']) ||
-
-
$Optional_Extras = $_POST['extras'];
-
-
if(strlen($Optional_Extras) < 2) {
-
$error_message .= 'The Extras you entered do not appear to be valid.<br />';
-
}
-
-
$email_message .= "Optional Extras: ".clean_string($extras)."\n";
-
-
!isset($_POST['accessories']) ||
-
-
$Accessory_Packs = $_POST['accessories'];
-
-
if(strlen($Accessory_Packs [2]) < 2) {
-
$error_message .= 'The Accessories you entered do not appear to be valid.<br />';
-
}
-
-
$email_message .= "Accessory Packs [2]: ".clean_string($accessories)."\n";
-
-
!isset($_POST['customer']) ||
-
-
$Customer_Specifics = $_POST['customer'];
-
-
if(strlen($Customer_Specifics) < 2) {
-
$error_message .= 'The Customer Specifics you entered do not appear to be valid.<br />';
-
}
-
-
$email_message .= "Customer Specifics: ".clean_string($customer)."\n";
-
-
!isset($_POST['budget'])) ||
-
-
$Maximum_Budget = $_POST['budget'];
-
-
if(strlen($Maximum_Budget) < 2) {
-
$error_message .= 'The Maximum Budget you entered do not appear to be valid.<br />';
-
}
-
-
$email_message .= "Maximum Budget: ".clean_string($budget)."\n";
-
The names on the HTML are the same as on the PHP so I think it's something I'm just failing to see.
That depends on what's being passed to the PHP page and whether or not they meet the validation you set.
This is the HTML code which makes up the form.
You have this in yor HTML: -
<select name="raid">
-
<option value="Choose"> </option>
-
<option value="Y">Yes*</option>
-
<option value="N">No</option>
-
</select>
And than in your php you have: -
$RAID = $_POST['raid'];
-
if(strlen($RAID) < 2) {
-
$error_message .= 'The RAID you entered do not appear to be valid.<br />';
-
}
-
-
$email_message .= "RAID: ".clean_string($raid)."\n";
This can only be valid for <option value="Choose"></option>
. http://php.net/manual/en/function.strlen.php
Also be careful with capital letters. In your HTML you have: - <input type="checkbox" name="Extras" value="TV"/>
and in your php - $Optional_Extras = $_POST['extras'];
Extras != extras
Inconsistencies like two I described are repeating.
Thought I had it fixed, but still have the error messages for RAID, Accessories and Guarantee.
RAID -
!isset($_POST['raid']) ||
-
-
$RAID = $_POST['raid'];
-
-
if(strlen($RAID) < 2) {
-
$error_message .= 'The RAID you entered do not appear to be valid.<br />';
-
}
-
-
$email_message3 .= "RAID: ".clean_string($RAID)."\n";
-
-
<tr>
-
<td align="left" valign="top">
-
<label for="raid">RAID </label> </td>
-
<td align="left" valign="top">
-
<select name="raid">
-
<option value="raid"> </option>
-
<option value="Y">Yes*</option>
-
<option value="N">No</option>
-
</select>
-
<span class="style8">(*Requires 2 identical Hard Drives)</span></td>
-
</tr>
-
Accessories -
!isset($_POST['accessories']) ||
-
-
$Accessory_Packs = $_POST['accessories'];
-
-
if(strlen($Accessory_Packs) < 2) {
-
$error_message .= 'The Accessories you entered do not appear to be valid.<br />';
-
}
-
-
$email_message9 .= "Accessory Packs: ".clean_string($Accessory_Packs)."\n";
-
-
<tr>
-
<td align="left" valign="top">
-
<label for="accessories">Accessory Packs [2]</label> </td>
-
<td align="left" valign="top">
-
<input type="checkbox" name="accessories" value="0" checked="checked"/>
-
None <br />
-
<input type="checkbox" name="accessories" value="1" />
-
Pack 1 <br />
-
<input type="checkbox" name="accessories" value="2" />
-
Pack 2 <br />
-
<input type="checkbox" name="accessories" value="3" />
-
Pack 3 <br />
-
<input type="checkbox" name="accessories" value="4" />
-
Pack 4 <br />
-
<input type="checkbox" name="accessories" value="5" />
-
Pack 5 <br />
-
<input type="checkbox" name="accessories" value="6" />
-
Pack 6 <br />
-
<input type="checkbox" name="accessories" value="Other" />
-
Other (Please Specify) <br /> </select> </td>
-
</tr>
-
Guarantee -
!isset($_POST['guarantee']) ||
-
-
$Guarantee = $_POST['guarantee'];
-
-
if(strlen($Guarantee) < 2) {
-
$error_message .= 'The Guarantee you entered do not appear to be valid.<br />';
-
}
-
-
$email_message10 .= "Guarantee: ".clean_string($Guarantee)."\n";
-
-
<tr>
-
<td align="left" valign="top">
-
<label for="guarantee">Guarantee </label> </td>
-
<td align="left" valign="top">
-
<select name="guarantee">
-
<option value="guarantee"> </option>
-
<option value="0">No Extension</option>
-
<option value="1">1 Year Extension</option>
-
<option value="2">2 Year Extension</option>
-
</select></td>
-
</tr>
-
Think I'm missing something here, but just can't seem to get it to work.
How do I get around this then? I don't understand what the link shows in respect to the errors in my PHP.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Wescotte |
last post by:
The error message Parse error: syntax error, unexpected $end in FILE on
line X is one I run into frequently and I know the cause is I missed an
ending quote.
Is there an easy way to determine...
|
by: kestrel |
last post by:
I have some html code that is supposed to be displayed by php echo. But for some reason i keep getting a syntax error, and i cant figure out what is going on.
Heres what i have
<?php...
|
by: rhys |
last post by:
My Gurus and Angels --
Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
|
by: SilvaZodiac |
last post by:
Hi everyone,
I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
|
by: paulrajj |
last post by:
hi to all,
i am getting syntax error on my code..
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\xampp\htdocs\Dummy\paulraj\matrim\exam.php on line 62
...
|
by: benicio |
last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19
I got this error and this syntax is from 8 to 19th line.
<?php
...
|
by: erone |
last post by:
Hello, good morning.
I have a syntax error here. Can you help? Thanks. It's a Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
on the "echo" line :
<?
$sql = "SELECT addrid,...
|
by: brkseven |
last post by:
Looking for help with this Contact Form.
The error is on line 1, but that' doesn't mean a lot, I think. In fact, a php syntax check passed it, but I was hoping for an easy syntax error, it looks...
|
by: vultren |
last post by:
Parse error: syntax error, unexpected $end in
I keep getting that, I have no clue where to fix it. Any help would be VERY APPRECIATED!
<?php
if(isset($_POST)) {
// EDIT THE 2 LINES...
|
by: Vicki Hendra |
last post by:
Hi
I am new to php fullstop
I and colleagues have setup wordpress blogs for our local towns, giving the local businesses free advertisment.
Part of the problem started when using wordpress...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |