Parse error: syntax error - Please Help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dman123
Forum Newbie
Posts: 2
Joined: Mon Dec 08, 2008 11:50 pm

Parse error: syntax error - Please Help!

Post by dman123 »

Hello,

I am having some trouble with processing a simple PHP web form. It needs to collect the data and send the email with the information within XML tags so that our system can grab it and put the details into our online booking system.

the error i get is:

Parse error: syntax error, unexpected T_DNUMBER in /home/totisme/public_html/test/form/aminew.php on line 70

and the php code is:

Code: Select all

<?php
// Receiving variables
 
@$FIRST = addslashes($_POST['FIRST']);
@$SURNAME = addslashes($_POST['SURNAME']);
@$DOB = addslashes($_POST['DOB']);
@$MOBILE = addslashes($_POST['MOBILE']);
@$ALTERNATE = addslashes($_POST['ALTERNATE']);
@$PREFERRED_TIME = addslashes($_POST['PREFERRED_TIME']);
@$AFFID = addslashes($_POST['AFFID']);
@$GETTING_ERECTION = addslashes($_POST['GETTING_ERECTION']);
@$KEEPING_ERECTION = addslashes($_POST['KEEPING_ERECTION']);
@$PREMATURE_EJACULATION = addslashes($_POST['PREMATURE_EJACULATION']);
@$Female_Sexual_Dysfunction = addslashes($_POST['Female_Sexual_Dysfunction']);
@$questionTxt = addslashes($_POST['questionTxt']);
 
// Validation
if (strlen($FIRST) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($SURNAME) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($DOB) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($MOBILE) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($PREFERRED_TIME) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($questionTxt) == 0 )
{
header("Location: error.html");
exit;
}
 
//Sending Email to form owner
$pfw_header = "From: drew.shardlow@totismedia.com\n"
  . "Reply-To: drew.shardlow@totismedia.com\n";
$pfw_subject = "New website booking";
$pfw_email_to = "shardlow@bigpond.net.au";
$pfw_message = "<?xml version="1.0" encoding="utf-8" ?>\n"
. "<MAIL xmlns="http://tempuri.org/HSFM_Mail.xsd">\n"
. "<ENTITY>HSFM</ENTITY>\n"
. "<SUBENTITY>ENQUIRY</SUBENTITY>\n"
. "<PATIENT_NAME>\n"
. "<FIRST>$FIRST</FIRST>\n"
. " <SURNAME>$SURNAME</SURNAME>\n"
. " <AFFID>$AFFID</AFFID>\n"
. "</PATIENT_NAME>\n"
. "<DOB>$DOB</DOB>\n"
. "<PHONE>\n"
. "<MOBILE>$MOBILE</MOBILE>\n"
. "<ALTERNATE>$ALTERNATE</ALTERNATE>\n"
. "</PHONE>\n"
. "<PREFERRED_TIME>$PREFERRED_TIME</PREFERRED_TIME>\n"
. "<QUESTIONNAIRE>\n"
. "<GETTING_ERECTION>$GETTING_ERECTION</GETTING_ERECTION>\n"
. "<KEEPING_ERECTION>$KEEPING_ERECTION</KEEPING_ERECTION>\n"
. "<PREMATURE_EJACULATION>$PREMATURE_EJACULATION</PREMATURE_EJACULATION>\n"
. "<Female_Sexual_Dysfunction>$Female_Sexual_Dysfunction</Female_Sexual_Dysfunction>\n"
. "<HOW_LONG>$questionTxt</HOW_LONG>\n"
. "<QUESTIONNAIRE>\n"
. "</MAIL>\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
 
header("Location: success.html");
 
?>
 
any help would be apreciated.

Thanks.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Parse error: syntax error - Please Help!

Post by requinix »

I looked a little. The error is not on line 70 in the code you posted, but a number of lines earlier.
Oh, and apparently I won't need to eat my shoe.


Find line 70 and look around until you see something with odd coloring. Strings are red except for metacharacters (backslash + something), variables are blue, comments are gray.

If there is nothing in the highlighting to suggest the source of the error I will eat my shoe.

Code: Select all

<?php
// Receiving variables
 
@$FIRST = addslashes($_POST['FIRST']);
@$SURNAME = addslashes($_POST['SURNAME']);
@$DOB = addslashes($_POST['DOB']);
@$MOBILE = addslashes($_POST['MOBILE']);
@$ALTERNATE = addslashes($_POST['ALTERNATE']);
@$PREFERRED_TIME = addslashes($_POST['PREFERRED_TIME']);
@$AFFID = addslashes($_POST['AFFID']);
@$GETTING_ERECTION = addslashes($_POST['GETTING_ERECTION']);
@$KEEPING_ERECTION = addslashes($_POST['KEEPING_ERECTION']);
@$PREMATURE_EJACULATION = addslashes($_POST['PREMATURE_EJACULATION']);
@$Female_Sexual_Dysfunction = addslashes($_POST['Female_Sexual_Dysfunction']);
@$questionTxt = addslashes($_POST['questionTxt']);
 
// Validation
if (strlen($FIRST) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($SURNAME) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($DOB) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($MOBILE) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($PREFERRED_TIME) == 0 )
{
header("Location: error.html");
exit;
}
 
if (strlen($questionTxt) == 0 )
{
header("Location: error.html");
exit;
}
 
//Sending Email to form owner
$pfw_header = "From: drew.shardlow@totismedia.com\n"
  . "Reply-To: drew.shardlow@totismedia.com\n";
$pfw_subject = "New website booking";
$pfw_email_to = "shardlow@bigpond.net.au";
$pfw_message = "<?xml version="1.0" encoding="utf-8" ?>\n"
. "<MAIL xmlns="http://tempuri.org/HSFM_Mail.xsd">\n"
. "<ENTITY>HSFM</ENTITY>\n"
. "<SUBENTITY>ENQUIRY</SUBENTITY>\n"
. "<PATIENT_NAME>\n"
. "<FIRST>$FIRST</FIRST>\n"
. " <SURNAME>$SURNAME</SURNAME>\n"
. " <AFFID>$AFFID</AFFID>\n"
. "</PATIENT_NAME>\n"
. "<DOB>$DOB</DOB>\n"
. "<PHONE>\n"
. "<MOBILE>$MOBILE</MOBILE>\n"
. "<ALTERNATE>$ALTERNATE</ALTERNATE>\n"
. "</PHONE>\n"
. "<PREFERRED_TIME>$PREFERRED_TIME</PREFERRED_TIME>\n"
. "<QUESTIONNAIRE>\n"
. "<GETTING_ERECTION>$GETTING_ERECTION</GETTING_ERECTION>\n"
. "<KEEPING_ERECTION>$KEEPING_ERECTION</KEEPING_ERECTION>\n"
. "<PREMATURE_EJACULATION>$PREMATURE_EJACULATION</PREMATURE_EJACULATION>\n"
. "<Female_Sexual_Dysfunction>$Female_Sexual_Dysfunction</Female_Sexual_Dysfunction>\n"
. "<HOW_LONG>$questionTxt</HOW_LONG>\n"
. "<QUESTIONNAIRE>\n"
. "</MAIL>\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
 
header("Location: success.html");
 
?>
live4eva_2
Forum Newbie
Posts: 4
Joined: Tue Dec 09, 2008 12:18 am

Re: Parse error: syntax error - Please Help!

Post by live4eva_2 »

I'm gonna eat my shoe...I'm dying to know what is the problem.
Oh and BTW this XML and php is so cool.I'm glad I know how to do it now!!
So let me get this straight(my XML is weak)..

1-This xml document is mailed to a email address.
2-The document is first verified against the schema(.xsd)
3-A transformation is applied to the document so that it is nicely formatted
and saved somewhere

right?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Parse error: syntax error - Please Help!

Post by requinix »

In the code I posted, look at lines 59-60. It should all be red (except the variable) to indicate a string but it is not: the strings have quotes right in the middle, breaking them.

You can replace the inner "s with 's instead (it'll work fine) or escape the quote by putting a backslash before it (\").
dman123
Forum Newbie
Posts: 2
Joined: Mon Dec 08, 2008 11:50 pm

Re: Parse error: syntax error - Please Help!

Post by dman123 »

1-This xml document is mailed to a email address.
2-The document is first verified against the schema(.xsd)
3-A transformation is applied to the document so that it is nicely formatted
and saved somewhere
this is correct. thanks
Post Reply