Jump to content


Photo

Parse error: syntax error, unexpected ':'


  • Please log in to reply
37 replies to this topic

#1 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 August 2006 - 08:34 PM

I am an EXTREME novice at this...

I am getting:

Parse error: syntax error, unexpected ':' in /export/home/ji/jill/public_html/consumerorder.php on line 28

What could that mean? The line reads:

Name: $visitor \n

This is for an email form.

Thanks


#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 09 August 2006 - 08:35 PM

it means that you're probably not actually echoing or appending that properly, and that the ":" is being parsed as actual PHP code.  give us the 5 lines before and after it, and we can probably tell you for certain.

#3 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 August 2006 - 09:08 PM

Here is more of it (not the while page)

If that is the case, how would I fix it?

As you can see, all the lines are similiar. I am not getting errors for other lines.

$visitor = $visitor;
$visitoraddress = $visitoraddress;
$paymentmethod = $paymentmethod; 
$posterstyle = $posterstyle;
$posterline = $posterline;
$playername = $playername;
$colors = $colors;
$maintext = $maintext;
$smalltext = $smalltext;
$playernumber = $playernumber;   
$mainphoto = $mainphoto;

Name: $visitor \n  (what appears to be the error line)
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
";

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 09 August 2006 - 09:17 PM

No, actually that is where the error begins. If you erase this line, the next one throw you an error as well.

What is the point of all this? $variable = $variable has no practical use.
And what do you want with the Name: $visitor and the subsequent lines?

Adding this right before that line should fix the error though:
$somevariable = "

~ D Kuang

#5 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 August 2006 - 09:27 PM

Likw I said, I am pretty clueless about PHP. I can create the form just fine, but getting it to work is another story.

I will try your suggestion. I thought I needed to set it up like that so it makes sense in the email.

#6 king arthur

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

Posted 09 August 2006 - 09:34 PM

Likw I said, I am pretty clueless about PHP. I can create the form just fine, but getting it to work is another story.

I will try your suggestion. I thought I needed to set it up like that so it makes sense in the email.

Perhaps I should just hire someone.


Well, what you have "created" is just a text file, it means nothing in PHP or even HTML. You will need to at least understand some of the basics of PHP syntax to start to get a script to do whatever it is you're trying to do.
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.

#7 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 August 2006 - 09:50 PM

There is more coding- that is just the area in question. 

#8 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 09 August 2006 - 09:51 PM

Post the whole code.

#9 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 09 August 2006 - 10:59 PM

if you're actually trying to send this, you will need to look into the mail() function.

however before that, you're going to need to learn a little more about PHP.  look on google for tutorials about how to deal with form information with PHP, and move on from there.  for starters, all information sent from the form is in either the $_POST array, or the $_GET array, depending on the method you're using.  most likely $_POST.

if you don't know what an array is, follow some basic tutorials on php.net.

#10 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 09 August 2006 - 11:57 PM

Here is the entire code:

<?php
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 = $playername;

$visitor = $visitor;
$visitoraddress = $visitoraddress;
$paymentmethod = $paymentmethod; 
$posterstyle = $posterstyle;
$posterline = $posterline;
$playername = $playername;
$colors = $colors;
$maintext = $maintext;
$smalltext = $smalltext;
$playernumber = $playernumber;     
$mainphoto = $mainphoto;

Name: $visitor \n
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
";

$from = "From: $visitormail\r\n";

mail("jillpearson@comcast.net", $subject, $visitor, $paymentmethod, $posterstyle, $posterline, $playername, $colors, $maintext, $smalltext, $playernumber, $mainphoto, $from);
?>
<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 610-873-0623.
</div>
<p align="center"> Date: <?php echo $todayis ?> <br />
  <?php echo $ip ?> <br />
<br />
<a href="www.jillpearson.com"> Next Page </a> </p>


#11 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 12:00 AM

BTW- Here is a weblink to the form this is susposed to go with.

http://www.jillpears.../orderconsumers

I copied it from a tutorial and altered it to fit my form. That is where something went wrong. When I used the tutorial samples on my website it worked just fine.

#12 ScottRiley

ScottRiley
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 10 August 2006 - 12:28 AM

That is really hard to read...

It seems you want the e-mail to include
"Name: $visitor \n
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"

I assume that's the case, because I can't think of any other use for that.

Firs of all, the variable declarations at the start could possibly be the biggest waste of code I've seen since the html for http://www.watching-...paint-dry.com.  You are basically updating a value of a certain variable, with the content of said variable.  Again, I'm assuming something, that you actually want this data to contain the information submitted in the form.

So, firstly, to get the information from the form.  Check yur HTML form for all instances of <data type="sometype" name="somename"....you need to replace the variables AFTER the '=' signs in your code, with $_POST['somename'] (if your form method is post, which it should be).  So, if the name of the field where the user inputs their 'postertype' in your HTML form has the value 'postertype' (i.e<data type="text" name="postertype"..) then you replace:

<?php
              $postertype = $postertpe; //lol
         ?>

with:
<?php
              $postertype = $_POST['postertype']; //that's better
         ?>

$_POST is used to collect information from a form with the method "post".  It stores all data fields of the fom in an array, with indicies relative to their instance name on the HTML form.  e.g. a field with the name 'i_should_learn_php' would be stored in the $_POST array as an index.  This index's name would be 'i_should_lean_php' and its value would be the data entered into the form.  $_POST['i_should_learn_php'] would contain the information entered into the form field with the name 'i_should_learn_php'.

Just repeat this until all variables actually contain values, not just copies of their blank selves (which is what your code currently chieves)

Now, I first mentioned that you would probably want the email to include the order status.

For this, you should create a new variable and call it $msg or something.

here you would store the list as a string $msg.
<?php
$msg="Name: $visitor \n
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
";
?>

then you would use the mail function.

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

maybe you should try learning PHP, the manual can be found on php.net and is a great resource.  I have the amazing total of a week's PHP experience, it's really not that hard to lean for someone of average intelligence.

Thank you for reading my help, my only hope is that it is as tedius..i mean...fun for you to code as it was for me to (agonisingly) write ot.  Good Night.

#13 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 12:36 AM

Wow, thanks! I will try that out when I get a chance.

Yes, I have been reading alot of tutorials on the web. Like I said, all I did was alter one that I found, which did not include $_POST. 

thanks again

#14 ScottRiley

ScottRiley
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 10 August 2006 - 12:45 AM

No problem, I'm just starting too, I've tried answering a few questions here, a) because I want to contribute a bit even if my knowledge isn't great and b) because when I'm trying to explain something, I can determine how well I understand it, after all, the art of learning a syntax is understanding what everything does, explaining and answerng questions are surefire ways to confirm you understand something.

#15 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 12:53 AM

Well, I made all the changes you suggested and now I am still getting an error
(unexpected T_VARIABLE) in line 19, which is simply

$posterstyle = $_POST['posterstyle'];

There are other $_POST in the code before it which do not cause errors, and it matches up with the "name" on my html form.



#16 king arthur

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

Posted 10 August 2006 - 12:54 AM

What is line 18?
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.

#17 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 01:09 AM

18 is

$paymentmethod = $_POST['paymentmethod'];

18, 19, and 20 are all drop down selections on my form. Do they need to be scripted differently since I'm not asking for whatever they wrote in, just what they SELECTED on the form?

#18 king arthur

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

Posted 10 August 2006 - 01:15 AM

Nothing wrong there, you'd better post the whole script 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.

#19 Jill78

Jill78
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 August 2006 - 01:25 AM

Here is the new script with Scott's suggestions:

<?php
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 = $playername;

$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'];

<?php
$msg="Name: $visitor \n
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
";
?>

<?php
mail({REMOVED BUT THIS PART WAS FINE}, $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>


#20 king arthur

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

Posted 10 August 2006 - 01:30 AM

Ah, you've confused the poor PHP interpreter! You don't need some of those opening and closing PHP tags ( <?php and ?> ), and there is one missing. Remove the ones on lines 28, 43 and 45.
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