| | |
NEED FORUM'S HELP ON "Parse error: syntax error"
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2008
Posts: 39
Reputation:
Solved Threads: 1
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
Please someone help me out to rewrite line 28(highlighted in green color) as pointed out by the feedback. It is urgent.
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.
O God! He that teaches man what he knows not, please grant us the solution.
PHP variables are case sensitive.
So
should be
Also, please surround your code with [code=php]php code here[/code] tags when posting.
$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)
if mail'('$Surname, $Othernames, $dateofbirth, $age, $sex')'
php Syntax (Toggle Plain Text)
if(mail($Surname, $OtherNames, $Dateofbirth, $age, $sex))
Also, please surround your code with [code=php]php code here[/code] tags when posting.
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
•
•
Join Date: Jul 2008
Posts: 148
Reputation:
Solved Threads: 25
php Syntax (Toggle Plain Text)
<?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(); } ?>
php Syntax (Toggle Plain Text)
<?PHP extract( $_POST, EXTR_PREFIX_ALL, 'post_' ); $target_address = 'info@uniqueeducationltd.com'; $sSubject = "Online Application Form Details"; $sMessage = 'Surname: ' . $post_Surname . "\n"; $sMessage . = 'Other Names: ' . $post_OtherNames . "\n"; $sMessage . = 'Date of Birth: ' . $post_Dateofbirth . "\n"; $sMessage . = 'Age: ' . $post_age . "\n"; $sMessage . = 'Sex: ' . $post_sex . "\n"; if ( mail( $target_address, $sSubject, $sMessage ) ) { 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(); }
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.
![]() |
Other Threads in the PHP Forum
- Previous Thread: php and word xml
- Next Thread: passing arrays to functions
| Thread Tools | Search this Thread |
ajax apache api array beginner binary broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip java javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop regex remote script search server sessions sms soap source space sql strip_tags subversion support! syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; xml youtube





