943,808 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 687
  • PHP RSS
Jan 20th, 2009
0

NEED FORUM'S HELP ON "Parse error: syntax error"

Expand Post »
I have been finding it difficult to understand the error statement I recieved from my php file using the code below. I keep on getting this result:
Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/username/public_html/application_form.php on line 28

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<?PHP
$Surname = $_POST['Surname'];
$OtherNames = $_POST['OtherNames'];
$Dateofbirth = $_POST['Dateofbirth'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$Nationality = $_POST['Nationality'];
$stateoforigin = $_POST['stateoforigin'];
$Entryclassonrequest = $_POST['Entryclassonrequest'];
$religion = $_POST['religion'];
$parentsguardiansname = $_POST['parents/guardiansname'];
$occupation = $_POST['occupation'];
$phonenumbers = $_POST['phonenumbers'];
$whomchildliveswith = $_POST['whomchildliveswith'];
$previousschool = $_POST['previousschool'];
$imunizationdetails = $_POST['imunizationdetails'];
$target_address = 'info@uniqueeducationltd.com';
$headers = "Online Application Form Details";
if mail'('$Surname, $Othernames, $dateofbirth, $age, $sex')' {
echo(("<p><font color=#333366"<b>Thank you for your application, we will get back to you as soon as we can.</b></p>"));
}
else{
echo("<p><font color=#008000"><span class="style1"><strong><font size="5">Sorry Your form submission had some errors. Try again later.</b></p>");
die();
}
?>
</body>
</html>


Please someone help me out to rewrite line 28(highlighted in green color) as pointed out by the feedback. It is urgent.
Last edited by peter_budo; Jan 21st, 2009 at 7:20 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 1
Light Poster
emiola is offline Offline
49 posts
since Jul 2008
Jan 20th, 2009
0

Re: NEED FORUM'S HELP ON "Parse error: syntax error"

PHP variables are case sensitive. $Othernames is not the same as $OtherNames and $dateofbirth is not the same as $Dateofbirth . There are also some syntax issues.

So
php Syntax (Toggle Plain Text)
  1. if mail'('$Surname, $Othernames, $dateofbirth, $age, $sex')'
should be
php Syntax (Toggle Plain Text)
  1. if(mail($Surname, $OtherNames, $Dateofbirth, $age, $sex))

Also, please surround your code with [code=php]php code here[/code] tags when posting.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Jan 20th, 2009
0

Re: NEED FORUM'S HELP ON "Parse error: syntax error"

php Syntax (Toggle Plain Text)
  1. <?PHP
  2. $Surname = $_POST['Surname'];
  3. $OtherNames = $_POST['OtherNames'];
  4. $Dateofbirth = $_POST['Dateofbirth'];
  5. $age = $_POST['age'];
  6. $sex = $_POST['sex'];
  7. $Nationality = $_POST['Nationality'];
  8. $stateoforigin = $_POST['stateoforigin'];
  9. $Entryclassonrequest = $_POST['Entryclassonrequest'];
  10. $religion = $_POST['religion'];
  11. $parentsguardiansname = $_POST['parents/guardiansname'];
  12. $occupation = $_POST['occupation'];
  13. $phonenumbers = $_POST['phonenumbers'];
  14. $whomchildliveswith = $_POST['whomchildliveswith'];
  15. $previousschool = $_POST['previousschool'];
  16. $imunizationdetails = $_POST['imunizationdetails'];
  17. $target_address = 'info@uniqueeducationltd.com';
  18. $headers = "Online Application Form Details";
  19. if mail'('$Surname, $Othernames, $dateofbirth, $age, $sex')' {
  20. echo(("<p><font color=#333366"<b>Thank you for your application, we will get back to you as soon as we can.</b></p>"));
  21. }
  22. else{
  23. echo("<p><font color=#008000"><span class="style1"><strong><font size="5">Sorry Your form submission had some errors. Try again later.</b></p>");
  24. die();
  25. }
  26. ?>

php Syntax (Toggle Plain Text)
  1. <?PHP
  2.  
  3. extract( $_POST, EXTR_PREFIX_ALL, 'post_' );
  4. $target_address = 'info@uniqueeducationltd.com';
  5. $sSubject = "Online Application Form Details";
  6.  
  7. $sMessage = 'Surname: ' . $post_Surname . "\n";
  8. $sMessage . = 'Other Names: ' . $post_OtherNames . "\n";
  9. $sMessage . = 'Date of Birth: ' . $post_Dateofbirth . "\n";
  10. $sMessage . = 'Age: ' . $post_age . "\n";
  11. $sMessage . = 'Sex: ' . $post_sex . "\n";
  12.  
  13. if ( mail( $target_address, $sSubject, $sMessage ) )
  14. {
  15. echo '<p><font color=#333366"<b>Thank you for your application, we will get back to you as soon as we can.</b></p>';
  16. }
  17. else
  18. {
  19. echo '<p><font color=#008000"><span class="style1"><strong><font size="5">Sorry Your form submission had some errors. Try again later.</b></p>';
  20. die();
  21. }

I used extract to simplify the creation of local variables based on the keys of your POST array. However, unless you're actually sanitizing or validating the data before it gets emails, which you should, there is no reason to create local variables. If you are emailing the raw data anyways, then just use the $_POST['key'] values directly. But, you should really be cleaning the input.

I also corrected your usage of mail()

**This is untested
Last edited by mschroeder; Jan 20th, 2009 at 12:19 pm.
Sponsor
Reputation Points: 265
Solved Threads: 126
Practically a Master Poster
mschroeder is offline Offline
624 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: php and word xml
Next Thread in PHP Forum Timeline: passing arrays to functions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC