Results 1 to 9 of 9
Related
-
Parse partial directory name Forum: CGI Perl Forum
Replies: 1 -
How to parse a file from checkbox input? Forum: PHP Forum
Replies: 0 -
Unexpected Error on Simple UPDATE Query Forum: PHP Forum
Replies: 8 -
Parse HTML Forum: PHP Forum
Replies: 4 -
How to parse lines of a reponse? Forum: CGI Perl Forum
Replies: 3
-
05-29-2007, 11:26 AM #1
Parse error, parse error unexpected T_variable. Help appreciated!
Hi,
I've just written my script (got my head around it at last (I hope). But now I've got this error message on line 65. I think it may be indicating I've missed something or haven't put anything in, but as a complete novice, I'm stumped. I would like to learn my own mistakes, so if someone, just on this one occasion could check my script to see if it's ok, and let me know where I've gone wrong around line 65 - then in future I can correct my mistakes. Very many thanks in anticipation. (Does anyone know of a good tutorial on how to php the form results in a better format when sending my email i.e., within a table??)
Here is lines 62 to 69 and then the full script is given below:
} else {
mail (myemailaddress@...."Account Application";
$companyname, $date, $name, "From: "$email");
header ("Location: http://linking to thank you page.htm");
$companyname = $_REQUEST['companyname'];
FULL SCRIPT (I've taken out the actual web addresses).
Code:<?php $page = "http://www.webaddress/AccountApplication.html"; if (!ereg($page, $_SERVER['HTTP_REFERER'])){ echo "Invalid referer"; die; } session_start(); session_register("SESSION"); if (!session_is_registered("SESSION")){ $errors[] = "Invalid form submission"; } $errors = array(); if (!$_POST['companyname']) $errors[] = "Company Name is required"; if (!$_POST['coaddress']) $errors[] = "company address is required"; if (!$_POST['cotelno']) $errors[] = "Telephone number is required"; if (!$_POST['regoffice']) $errors[] = "Registered Office is required"; if (!$_POST['coregno']) $errors[] = "Company Registration no is required"; if (!$_POST['accscontact']) $errors[] = "Accounts contact is required"; if (!$_POST['accstelno']) $errors[] = "Accounts telephone no is required"; if (!$_POST['accsemail']) $errors[] = "Accounts Email is required"; if (!$_POST['despatch']) $errors[] = "Despatch detail is required"; if (!$_POST['despatchtel']) $errors[] = "Despatch tel no is required"; if (!$_POST['despatchemail']) $errors[] = "Despatch Email is required"; if (!$_POST['bankdetails']) $errors[] = "Bank details is required"; if (!$_POST['bankaccountno']) $errors[] = "Bank Account no is required"; if (!$_POST['bankersname']) $errors[] = "Bankers Name is required"; if (!$_POST['sortcode']) $errors[] = "Sort code is required"; if (!$_POST['bankersaddress']) $errors[] = "Bankers address is required"; if (!$_POST['ref1']) $errors[] = "Reference is required"; if (!$_POST['ref2']) $errors[] = "Reference is required"; if (!$_POST['name']) $errors[] = "Name is required"; if (!$_POST['date']) $errors[] = "Date is required"; if (!$_POST['telno']) $errors[] = "Telephone no is required"; if (count($errors)>0){ echo "<strong>ERROR:<br>\n"; foreach($errors as $err) echo "$err<br>\n"; } else { mail ("hmc@futureitsystems.co.uk", "Account Application"; $companyname, $date, $name, "From: "$email"); header ("Location: http://webaddress/Thank you.htm"); $companyname = $_REQUEST['companyname']; $coaddress = $_REQUEST['coaddress']; $cotelno = $_REQUEST['cotelno']; $regoffice = $_REQUEST['regoffice']; $coregno = $_REQUEST['coregno']; $accscontact = $_REQUEST['accscontact']; $accstelno = $_REQUEST['accstelno']; $accesemail = $_REQUEST['accsemail']; $accsfaxno = $_REQUEST['accsfaxno']; $despatch = $_REQUEST['despatch']; $despatchtel = $_REQUEST['despatchtel']; $despatchemail = $_REQUEST['despatchemail']; $despatchfax = $_REQUEST['despatchfax']; $bankdetails = $_REQUEST['bankdetails']; $bankaccountno = $_REQUEST['bankaccountno']; $bankersname = $_REQUEST['bankersname']; $sortcode = $_REQUEST['sortcode']; $bankersaddress = $_REQUEST['bankersaddress']; $ref1 = $_REQUEST['ref1']; $ref2 = $_REQUEST['ref2']; $name = $_REQUEST['name']; $postion = $_REQUEST['position']; $date = $_REQUEST['date']; $telno = $_REQUEST['telno']; } $to="me@company"; $from="companyname"; $subject="Account Application"; $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/alternative;\n" . " boundary=\"{$mime_boundary}\"\r\n"; $headers.= "From: $from\r\n"; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . "HTML E-mail\n\nThis is the text portion of an HTML e-mail\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . "<h1>HTML E-mail</h1>" . "<p>This is an <b>HTML</b> e-mail.</p>"; if (mail($to, $subject, $message, $headers)) echo "Message Sent!"; else echo "Failed to send message."; if (!isset($_REQUEST['email'])) { header ( "Location: http://companywebaddress/AccountApplication.html" ); } elseif (empty($email($email) || empty ($companyname)) { header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); header( "Last-Modified: .gmdate("D, d M Y H:i:s") . "GMT"); header( "Cache-Control: no-cache, must-revalidate"); header( "Pragma: no-cache" ); ?> <html> <head><title>Error</title></head> <body> <h1>Error</h1> <p> Sorry, the form has not been filled out correctly. Please press your BACK button in your browser and try again. </p> </body> </html> <? } else { mail ("me@webaddress", "AccountApplication", $companyname, "From: $email"); header ("Location: http://www.companywebaddress/Thank you.htm"); } ?>
Last edited by vinyl-junkie; 05-29-2007 at 07:19 PM. Reason: Added code tags
-
05-29-2007, 11:58 AM #2
Re: Parse error, parse error unexpected T_variable. Help appreciated!
First thing about these errors is to normally check for incorrect syntax in the preceeding line. An unexpected t_variable usually means you haven't closed brackets, or put in the closing curly brace etc.
The mail function takes the form
mail ($to, $subject, $message, $headers);
In your code you have a closing bracket after..@...."Account Application";
Not sure that should be there so try removing that??.
-
05-29-2007, 12:22 PM #3
Re: Parse error, parse error unexpected T_variable. Help appreciated!
Thanks for the quick reply. I see what you mean. Does it matter where things are placed - basically is there an order? Does the mail function ( ) need to be at the top and are you saying mine is not written correctly? If so, I'll change. Do you think otherwise it looks in order?
-
05-30-2007, 04:54 AM #4
Re: Parse error, parse error unexpected T_variable. Help appreciated!
No it doesn't really matter where things are placed except when you call the mail function to have it in the order above.
Everything else looks fine. Did that get rid of the error???
-
05-30-2007, 05:42 AM #5
Re: Parse error, parse error unexpected T_variable. Help appreciated!
Thanks for the quick response and for having a look at the code, appreciated.
It hasn't worked, but it may be there's something before or after that line, so I'm about to go through with a fine toothcomb and see. Keep you posted.
Thanks again
-
05-31-2007, 02:46 PM #6
Re: Parse error, parse error unexpected T_variable. Help appreciated!
Hi, thought I'd let you know, I went through the whole script today and most of last night and then rewrote some of it. Eventually, it did work only because I found out that I was missing a line above the mail () function that my host insists on otherwise it wouldn't work and after some more tweaking, eventually got it to work!! Hurray! Thanks very much for your appreciated help. By the way, just one small thing, when I get the reply email. it shows all the contents one after the other but then the last five are 'bunched' together? Do you know of a way I can make the results come back in an email more appeasing to the user?
-
05-31-2007, 06:17 PM #7
Re: Parse error, parse error unexpected T_variable. Help appreciated!
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
-
06-01-2007, 06:09 AM #8
Re: Parse error, parse error unexpected T_variable. Help appreciated!
Do you mean they're not on seperate lines??
Try '\n' after your data??
Great to know you got it working. These things can make you bang your head against a wall especially when you're sure the code is right
-
06-01-2007, 02:16 PM #9
Re: Parse error, parse error unexpected T_variable. Help appreciated!
Hi,
Bang my head against a wall? I nearly jumped out the window - computer with me!!!!!!!!!! It's all at last starting to sink in to this brain of mine, although no doubt still a far way to go. The bunching - what I mean is when the email comes back it will look something like this:
Name : Bob
Company: My Company
Email : me@
I like : lad di da
TelNO: 8989898Fax No:989898My interests:None,I'boring etc.
The last few are just on one line, with the others one after another above. However, as on Windows, I do have \r\n; on each line so I don't understand??? Is one line after the other, if it all eventually works for me, the only way, or can you implement some kind of table or highlight the variables? By the way, I sleep, think, eat php now and have an unusual desire for semi-colons in everything - is this normal?!
Many thanks - I obviously decided against jumping!