Jill78 Posted August 9, 2006 Share Posted August 9, 2006 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 28What could that mean? The line reads:Name: $visitor \nThis is for an email form.Thanks Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 9, 2006 Share Posted August 9, 2006 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. Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 9, 2006 Author Share Posted August 9, 2006 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 \nPoster Style: $posterstyle \nPoster Line: $posterline \nPlayer Name: $playername \nColors: $colors \nMain Text: $maintext \nSmall Text: $smalltext \nPlayer Number: $playernumber \nMain Photo: $mainphoto \nAdditional Info: IP = $ip \nBrowser Info: $httpagent \nReferral: $httpref \n"; Quote Link to comment Share on other sites More sharing options...
poirot Posted August 9, 2006 Share Posted August 9, 2006 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] Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 9, 2006 Author Share Posted August 9, 2006 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. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 9, 2006 Share Posted August 9, 2006 [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. Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 9, 2006 Author Share Posted August 9, 2006 There is more coding- that is just the area in question. Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 9, 2006 Share Posted August 9, 2006 Post the whole code. Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 9, 2006 Share Posted August 9, 2006 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. Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 9, 2006 Author Share Posted August 9, 2006 Here is the entire code:<?phpif(!$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 \nPayment Method: $paymentmethod \nPoster Style: $posterstyle \nPoster Line: $posterline \nPlayer Name: $playername \nColors: $colors \nMain Text: $maintext \nSmall Text: $smalltext \nPlayer Number: $playernumber \nMain Photo: $mainphoto \nAdditional Info: IP = $ip \nBrowser Info: $httpagent \nReferral: $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> Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 10, 2006 Author Share Posted August 10, 2006 BTW- Here is a weblink to the form this is susposed to go with.http://www.jillpearson.com/orderconsumersI 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. Quote Link to comment Share on other sites More sharing options...
ScottRiley Posted August 10, 2006 Share Posted August 10, 2006 That is really hard to read...It seems you want the e-mail to include"Name: $visitor \nPayment Method: $paymentmethod \nPoster Style: $posterstyle \nPoster Line: $posterline \nPlayer Name: $playername \nColors: $colors \nMain Text: $maintext \nSmall Text: $smalltext \nPlayer Number: $playernumber \nMain Photo: $mainphoto \nAdditional Info: IP = $ip \nBrowser Info: $httpagent \nReferral: $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 \nPayment Method: $paymentmethod \nPoster Style: $posterstyle \nPoster Line: $posterline \nPlayer Name: $playername \nColors: $colors \nMain Text: $maintext \nSmall Text: $smalltext \nPlayer Number: $playernumber \nMain Photo: $mainphoto \nAdditional Info: IP = $ip \nBrowser Info: $httpagent \nReferral: $httpref \n";?>[/code]then you would use the mail function.[code]<?phpmail("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. Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 10, 2006 Author Share Posted August 10, 2006 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 Quote Link to comment Share on other sites More sharing options...
ScottRiley Posted August 10, 2006 Share Posted August 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 10, 2006 Author Share Posted August 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 10, 2006 Share Posted August 10, 2006 What is line 18? Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 10, 2006 Author Share Posted August 10, 2006 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? Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 10, 2006 Share Posted August 10, 2006 Nothing wrong there, you'd better post the whole script again. Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 10, 2006 Author Share Posted August 10, 2006 Here is the new script with Scott's suggestions:<?phpif(!$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 \nPayment Method: $paymentmethod \nPoster Style: $posterstyle \nPoster Line: $posterline \nPlayer Name: $playername \nColors: $colors \nMain Text: $maintext \nSmall Text: $smalltext \nPlayer Number: $playernumber \nMain Photo: $mainphoto \nAdditional Info: IP = $ip \nBrowser Info: $httpagent \nReferral: $httpref \n";?><?phpmail({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> Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 10, 2006 Share Posted August 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 10, 2006 Share Posted August 10, 2006 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] Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 10, 2006 Author Share Posted August 10, 2006 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> Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 10, 2006 Share Posted August 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 10, 2006 Share Posted August 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
Jill78 Posted August 10, 2006 Author Share Posted August 10, 2006 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']; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.