PDA

View Full Version : parse error



rypurvis
11-02-2006, 08:10 PM
I receive this error message when I click submit on my contact page (www.cateredvibes.com/contactus.html (http://www.cateredvibes.com/contactus.html))

Parse error: syntax error, unexpected '[' in /home2/zomjwzgn/public_html/process123.php on line 70

How do I correct this? Please help!

Here is my full script:

<?php
$advertisement = $HTTP_POST_VARS['advertisement'];
$name = $HTTP_POST_VARS['name'];
$phone = $HTTP_POST_VARS['phone'];
$city = $HTTP_POST_VARS['city'];
$email = $HTTP_POST_VARS['email'];
$event = $HTTP_POST_VARS['event'];
$date = $HTTP_POST_VARS['date'];
$guests = $HTTP_POST_VARS['guests'];
$start = $HTTP_POST-VARS['start'];
$end = $HTTP_POST_VARS['end'];
$details = $HTTP_POST_VARS['details'];
if (strlen($advertisement) == 0)
{
echo "It appears that you have forgot to fill in the How did you hear about us? field. Please use the Back Button to return to the form and fill in How you
heard about us. Thank you!";
exit;
}
if (strlen($advertisement) >=30)
{
echo "The length limit for the How did you hear about us? field cannot exceed 30 characters / spaces. Please use the Back Button to return to the form and
shorten this entry. Thank you!";
exit;
}
if (strlen($name) == 0)
{
echo "It appears that you have forgot to fill in your name in the Name field. Please use the Back Button to return to the form and enter your name. Thank
you!";
exit;
}
if (strlen($name) >=30)
{
echo "The length limit for the Name field cannot exceed 30 characters / spaces. Please use the Back Button to return to the form and shorten this entry.
Thank you!";
exit;
}
if (strlen($phone) == 0)
{
echo "It appears that you have forgot to fill in your phone number. Please use the Back Button to return to the form and enter your number. Thank you!";
exit;
}
if (strlen($phone) >=14)
{
echo "Your phone number cannot exceed 14 characters / spaces. Please use the Back Button to return to the form and shorten this entry. Thank you!";
exit;
}
if (strlen($city) == 0)
{
echo "It appears that you have forgot to fill in your City, STate, and Zip. Please use the Back Button to return to the form and enter that information.
Thank you!";
exit;
}
if (strlen($city) >=30)
{
echo "The length limit for the City, St Zip field cannot exceed 30 characters / spaces. Please use the Back Button to return to the form and shorten this
entry. Thank you!";
exit;
}
if (strlen($email) == 0)
{
echo "The E-mail field is a required entry. Please use the Back Button to return to the form and enter a contact E-mail address. Thank you!";
exit;
}
if (strlen($email) >= 45)
{
echo "The length limit for the E-Mail field cannot exceed 45 characters / spaces. Please use the Back Button to return to the form and shorten this entry.
Thank you!";
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
echo "I believe that there is an error in the way you entered your E-mail address. Please check your entry and re-submit. Thank you!";
exit;
}
if (strlen($event) == 0)
{
echo "It appears that you have forgot to fill in your type of event. Please use the Back Button to return to the form and enter your event type. Thank
you!";
exit;
}
if (strlen($event) >=30)
{
echo "The length limit for the Name field cannot exceed 30 characters / spaces. Please use the Back Button to return to the form and shorten this entry.
Thank you!";
exit;
}
if (strlen($date) == 0)
{
echo "It appears that you have forgot to fill in your the date of your event. Please use the Back Button to return to the form and enter the event date.
Thank you!";
exit;
}
if (strlen($date) >=18)
{
echo "The length limit for the Name field cannot exceed 18 characters / spaces. Please use the Back Button to return to the form and shorten this entry.
Thank you!";
exit;
}
if (strlen($guests) == 0)
{
echo "It appears that you have forgot to fill in the number of guests you expect to attend. Please use the Back Button to return to the form and enter the
estimated number of guest that you expect to attend. Thank you!";
exit;
}
if (strlen($guests) >=6)
{
echo "The length limit for the Name field cannot exceed 6 characters / spaces. Please use the Back Button to return to the form and shorten this entry.
Thank you!";
exit;
}
if (strlen($start) == 0)
{
echo "It appears that you have forgot to fill in your start time. Please use the Back Button to return to the form and enter what time your event starts.
Thank you!";
exit;
}
if (strlen($start) >=8)
{
echo "The length limit for the Name field cannot exceed 8 characters / spaces. Please use the Back Button to return to the form and shorten this entry.
Thank you!";
exit;
}
if (strlen($end) == 0)
{
echo "It appears that you have forgot to fill in your end time. Please use the Back Button to return to the form and enter what time your event ends. Thank
you!";
exit;
}
if (strlen($end) >=8)
{
echo "The length limit for the Name field cannot exceed 8 characters / spaces. Please use the Back Button to return to the form and shorten this entry.
Thank you!";
exit;
}
if (strlen($details) >= 300)
{
echo "The details of your setup and meal area is limited to 300 characters / spaces. It appears that you have exceeded that limit. Please use the back
button to return to the form and shorten this entry.Thank you!";
exit;
}
if (substr_count($comments , '@') > "2")
{
echo "For security reasons this text (comments) area limits the number of @ symbols that can appear within it. It would appear that you have exceeded that
number. Please use the Back Button to return to the form and correct this. Thank you for your patience!";
exit;
}
//SEND MAIL
$mailto = "bob@cateredvibes.com";
$mailsubj = "Catering Inquiry Form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Website Submission form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
echo "Thank you for visiting our site and filling out our form. We will get back to you within 48 hours!";
?>

navaldesign
11-03-2006, 04:43 AM
I haven't checked for other errors, but the one that gives you this problem is in line 9 of your script (it then becomes line 70 probably because you have pasted it in a html page) : it is:

$start = $HTTP_POST-VARS['start'];

instead of the correct $start = $HTTP_POST_VARS['start'];

rypurvis
11-03-2006, 10:06 PM
That worked. What did you mean by "pasting it in html." How else should I have done it?
Thanks for all your help. Please keep in mind that I am a novice at this.

navaldesign
11-04-2006, 06:10 AM
What i meant is that when you paste the code in a html box in a page, the numbering of lines takes into account ALL the lines, not only the php script lines. So the error line number is by no means indicating the actual line where the error is. If f.e. the error is in line 10 of the script, (as it is actually) but your page has 60 lines BEFORE the script starts, the server will report the error in line 10+60=70 (as it did) , so the error line number is not helpfull at all.

This script could also have worked as a standalone, in which case the error line number reported by the server would be 10.

rypurvis
11-07-2006, 03:48 PM
Thanks. You've been a great help.