Jump to content


Photo

Parse error: syntax error, unexpected ':'


  • Please log in to reply
37 replies to this topic

#21 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 August 2006 - 01:31 AM

You'll need move all the var = $_POST['var'] section of code AHEAD of any testing you want to do with user inputs, i.e. put it at the start.

You could/should do a little more with the inputs that don't come from dropdowns so that whitespace and 'code' gets removed from it. e.g.

$visitor = strip_tags(trim($_POST['visitor'])); // remove whitespace at ends and html, etc.

Legend has it that reading the manual never killed anyone.
My site

#22 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 01:45 AM

I removed lines and moved the $_POST['var'] section ahead and now I'm still getting and error, this time for line 6, which was the same line from before!

$posterstyle = $_POST['posterstyle'];


??????

I just don't see anything wrong with this! On my form it reads:

Poster Style:<br />
<select name="posterstyle" size="1">
<option value=" Bronze-12x18 ">Bronze-12x18 </option>
<option value=" Silver-16x20 ">Silver-16x20 </option>
<option value=" Gold-20x30 ">Gold-20x30 </option>
</select>

#23 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 August 2006 - 01:50 AM

The select in the form is fine. The php line you posted is fine.  Most likely the error (whatever it was - we don't know) relates to an earlier line. Post the code you're using right now from the beginning to line 6.
Legend has it that reading the manual never killed anyone.
My site

#24 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 10 August 2006 - 01:51 AM

You should remove your personal email and phone number from your post above!!

Also, you can quickly do
$visitor = $_POST['visitor'];
$visitoraddress = $_POST['visitoraddress'];
$paymentmethod = $_POST['paymentmethod'];
$posterstyle = $_POST['posterstyle'];
$posterline = $_POST['posterline'];
$playername = $_POST['playername'];
$colors = $_POST['colors'];
$maintext = $_POST['maintext'];
$smalltext = $_POST['smalltext'];
$playernumber = $_POST['playernumber'];     
$mainphoto = $_POST['mainphoto'];

by using extract:

extract($_POST);

Then, as AndyB suggested, make sure to remove anything malicious that the user may have input.

#25 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 02:40 PM

Here it is from the beginning. I changed the address to have street, city etc.  It's still giving me an error on line 10, which is the posterstyle line again! It is  "unexpected T_VARIABLE"


<?php

$visitor = $_POST['visitor'];
$visitoremail = $_POST['visitoremail'];
$visitorstreet = $_POST['visitorstreet'];
$visitorcity = $_POST['visitorcity'];
$visitorstate = $_POST['visitorstate'];
$visitorzipcode = $_POST['visitorzipcode'];
$paymentmethod = $_POST['paymentmethod'];
$posterstyle = $_POST['posterstyle'];
$posterline = $_POST['posterline'];

#26 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 02:44 PM

Odd. Try replacing that whole lot with
extract($_POST);

(that will do the exact same thing as all those lines). Then see if you still get an error.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#27 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 August 2006 - 02:51 PM

There is absolutely no syntax error resulting from those lines as posted. I copied them to my own server and they give no error at all.  Are you sure you have uploaded the current/edited version to your server?
Legend has it that reading the manual never killed anyone.
My site

#28 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 02:54 PM

Andy- yes!  So it works for you? That is so odd. Could it be my browser? I don't get it....

King Arthur- I don't get you you mean... replace the whole thing?

#29 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 02:56 PM

Replace all the lines you posted with just the one single line I posted.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#30 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 03:00 PM

I tried replacing with the single line, now it is line 41

mail("jillpearson@comcast.net", $subject, $msg, "Jill");

#31 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 03:06 PM

There must still be something in your script that is throwing the PHP interpreter. Post the whole thing again.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#32 ScottRiley

ScottRiley
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 10 August 2006 - 03:08 PM

when telling us your code, you need to post more than just the line with the orror, post about 5 lines below and 5 lines above the error too

#33 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 03:19 PM

Here is the code that Andy tried out (I think) and it worked for him, but I got an error on the line reading:  $posterstyle = $_POST['posterstyle'];

When I replaced the upper part with  extract($_POST), then I would get the error on this line:

mail("jillpearson@comcast.net", $subject, $msg, "Jill");



<?php

$visitor = $_POST['visitor'];
$visitoremail = $_POST['visitoremail'];
$visitorstreet = $_POST['visitorstreet'];
$visitorcity = $_POST['visitorcity'];
$visitorstate = $_POST['visitorstate'];
$visitorzipcode = $_POST['visitorzipcode'];
$paymentmethod = $_POST['paymentmethod'];
$posterstyle = $_POST['posterstyle'];
$posterline = $_POST['posterline'];
$playername = $_POST['playername'];
$colors = $_POST['colors'];
$maintext = $_POST['maintext'];
$smalltext = $_POST['smalltext'];
$playernumber = $_POST['playernumber'];     
$mainphoto = $_POST['mainphoto'];


if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a") ;

$subject = $visitor;


$msg="
Name: $visitor \n
Email: $visitoremail \n
Street: $visitorstreet\n
City: $visitorcity \n
State: $visitorstreet \n
Zip Code: $visitorzipcode
Payment Method: $paymentmethod \n
Poster Style: $posterstyle \n
Poster Line: $posterline \n
Player Name: $playername \n
Colors: $colors \n
Main Text: $maintext \n
Small Text: $smalltext \n
Player Number: $playernumber \n
Main Photo: $mainphoto \n
Additional Info: IP = $ip \n
Browser Info: $httpagent \n
Referral: $httpref \n
";

mail("me@comcast.net", $subject, $msg, "Jill");
?>

<div align="center">Thank you for you order. If you do not receive personalized
  order confirmation from us within two business days, please call us at 555-555-5555.
</div>
<p align="center"> Date: <?php echo $todayis ?> <br />
  <?php echo $ip ?> <br />
  <br />
  <a href="sportsposters"> Next Page </a> </p>


#34 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 03:23 PM

Hey andy- your order test came through to my email!

So then maybe this is an issue with my server???



#35 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 August 2006 - 03:26 PM

There's quite a few things that aren't quite right with the info that gets asked for and the info that gets sent, but that's all trivial stuff to fix later.

Fact is - it works on my server (from a client URL, but what the heck) - http://www.brianasht.../orderform.html - as you now know.

If you want to send me the complete order form and order form processing script (email to andy@halfadot.com), I'll get it working on my server and then - if needed - you can approach your web host and ask "how come this works on X and bombs on my server"
Legend has it that reading the manual never killed anyone.
My site

#36 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 03:28 PM

Try replacing the whole thing with this and see if you are still getting similar errors.

<?php

extract($_POST);

if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a") ;

$subject = $visitor;


$msg="
Name: $visitor \n
Email: $visitoremail \n
Street: $visitorstreet\n
City: $visitorcity \n
State: $visitorstreet \n
Zip Code: $visitorzipcode
Payment Method: $paymentmethod \n
Poster Style: $posterstyle \n
Poster Line: $posterline \n
Player Name: $playername \n
Colors: $colors \n
Main Text: $maintext \n
Small Text: $smalltext \n
Player Number: $playernumber \n
Main Photo: $mainphoto \n
Additional Info: IP = $ip \n
Browser Info: $httpagent \n
Referral: $httpref \n
";

mail("me@comcast.net", $subject, $msg, "Jill");

echo "<div align=\"center\">Thank you for you order. If you do not receive personalized 
  order confirmation from us within two business days, please call us at 555-555-5555.
</div>
<p align=\"center\"> Date: $todayis 
 <a href=\"sportsposters\"> Next Page </a> </p> ";

?>

Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#37 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 03:47 PM

That gave me:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /export/home/ji/jill/public_html/consumerorder7.php on line 3

Whatever I had before was working on Andy's server.  So I guess this is an issue with my server at this point. I'll contact them.

Thanks all so much for your help.


#38 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 03:57 PM

It could be a lot of things. It could be your version of PHP or your error settings. You could put the line "phpInfo();" near the start of your script just temporarily and see what you can make of the info it prints out.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users