| | |
please help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
•
•
Join Date: Dec 2008
Posts: 5
Reputation:
Solved Threads: 0
I keep getting this message what is wrong with my sacript???
Parse error: syntax error, unexpected $end in /home/sites/thefieldinggallery.co.uk/web/contact_form.php on line 65
here is the php script:
Parse error: syntax error, unexpected $end in /home/sites/thefieldinggallery.co.uk/web/contact_form.php on line 65
here is the php script:
php Syntax (Toggle Plain Text)
<?php /* subject and email Variables */ $emailSubject = 'Crazy PHP Scripting'; $webMaster = 'info@thefieldinggallery.co.uk'; /* Gathering Data Variables */ $nameField = $_POST['name']; $surnameField = $_POST['surname']; $emailField = $_POST['email']; $telephoneField = $_POST['telephone']; $commentsField = $_POST['comments']; $body = <<<em <br><hr><br> name: $name <br> surname: $surname <br> email: $email <br> telephone: $telephone <br> comments: $comments <br> EOD; $headers = "From: $email\r\n"; $headers ,= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /*Results rendered as HTML */ $theResults = <<<EOD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="50%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><img src="images/strap.jpg" alt="header" width="769" height="216" /></td> </tr> <tr> <td width="11%"><div align="center"><a href="index.html">Back to Home</a></div></td> <td width="89%"><div align="center"> <p> </p> <p><font color="#FF0000" size="+7"><u>Thank you</u> <font color="#000000">for your we have recived you Questions / Comments and we will reply to you</font> <u>as soon as possible</u></font></p> </div></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><div align="right">Copyright © <a href="http://www.thefieldinggallery.co.uk">www.thefieldinggallery.co.uk</a></div></td> </tr> </table> </body> </html> EOD; echo "$theresults"; ?>
Last edited by peter_budo; Dec 2nd, 2008 at 8:07 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
When using heredoc, you must open and close the variable with the same identifier. should be:
Also, variables in php are case sensitive, so you'll have a blank page unless you change
php Syntax (Toggle Plain Text)
$body = <<<em <br><hr><br> name: $name <br> surname: $surname <br> email: $email <br> telephone: $telephone <br> comments: $comments <br> EOD;
php Syntax (Toggle Plain Text)
$body = <<<EOD <br><hr><br> name: $name <br> surname: $surname <br> email: $email <br> telephone: $telephone <br> comments: $comments <br> EOD;
Also, variables in php are case sensitive, so you'll have a blank page unless you change
echo "$theresults"; to echo "$theResults"; Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
Next time, wrap your code in code tags when posting to keep things neat. There are plenty of people here to help out. Keeping things neat will improve your chances of getting help.
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
Wrap the code like so:
[code=php]Code goes here[/code]
As to your problem, your email contains undefined variables. For instance you define namefield as
[code=php]Code goes here[/code]
As to your problem, your email contains undefined variables. For instance you define namefield as
$nameField = $_POST['name']; but in the email you send, you have the undefined variable $name instead of the defined $nameField. Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
The name the element has in the form goes inside the brackets.
So if your form has
After the form is submitted, PHP can assign the value posted to the variable. Here we assign the value of the textbox above to the variable $nameField:
Now if you want to use that variable in your email, you'll need to use the variable just defined.
Get it??
So if your form has
html Syntax (Toggle Plain Text)
<input name="name" type="text" id="name" tabindex="16" />
php Syntax (Toggle Plain Text)
$nameField=$_POST['name'];
php Syntax (Toggle Plain Text)
$body = <<<EOD <br><hr><br> name: $nameField <br>
Get it??
Lost time is never found again.
- Benjamin Franklin
- Benjamin Franklin
![]() |
Other Threads in the PHP Forum
- Previous Thread: how can I have a thumb frame of a movie, like youtube
- Next Thread: Getting Future Date
| Thread Tools | Search this Thread |
.htaccess access alexa apache api array autocomplete beginner broken cakephp class cms code convert cron curl database dataentry date directory display dropdown duplicates dynamic email emptydisplayvalue encode error execute explodefunction fairness file firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include indentedsubcategory ip javascript joomla keywords limit link login mail menu methods multiple multipletables mysql network newsletters object oop passwords paypal pdf php provider query radio random recursive redirect remote script search secure securephp server sessions shot simple source space sql subscription system table tutorial tutorials upload url user validator variable video voteup web youtube





