Jump to content

Parse error: syntax error, unexpected ':'


Jill78

Recommended Posts

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
Link to comment
Share on other sites

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
";
Link to comment
Share on other sites

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:
[code=php:0]$somevariable = "[/code]
Link to comment
Share on other sites

[quote author=Jill78 link=topic=103613.msg412730#msg412730 date=1155158832]
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.
[/quote]

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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>
Link to comment
Share on other sites

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

http://www.jillpearson.com/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.
Link to comment
Share on other sites

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:

[code]<?php
              $postertype = $postertpe; //lol
        ?>[/code]

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

$_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.
[code]<?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
";
?>[/code]

then you would use the mail function.

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

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>
Link to comment
Share on other sites

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.

[code]$visitor = strip_tags(trim($_POST['visitor'])); // remove whitespace at ends and html, etc.[/code]
Link to comment
Share on other sites

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>
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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

Also, you can quickly do
[code]$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'];[/code]

by using extract:

[code]extract($_POST);[/code]

Then, as AndyB suggested, make sure to remove anything malicious that the user may have input.
Link to comment
Share on other sites

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'];
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.