473,837 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse Error

1 New Member
I have a pretty limited knowledge of PHP.

My scenario is:

I want one form to have two (2) submit buttons. I want one button to submit an email to a specific address then redirect to a page, and I want the second one to submit to the same email, then redirect to a different page. I've downloaded some code, so I can't take credit for it, but I'm trying to use my basic knowledge to create and IF and ELSE IF. Right now, I'm just trying to get the code to work at all, so I have the form simply submitting the form data to an email address based on the button that was clicked.

I get the following parse error:

Parse error: syntax error, unexpected T_ELSE in /home/salamone/public_html/sendeail.php on line 65

Code:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Sendemail Script</title>
  7. </head>
  8. <body>
  9.  
  10. <?php
  11.  
  12.  
  13.  
  14.  
  15.  
  16. $ip = $_POST['ip'];
  17. $httpref = $_POST['httpref'];
  18. $httpagent = $_POST['httpagent'];
  19. $visitor = $_POST['visitor'];
  20. $visitormail = $_POST['visitormail'];
  21. $notes = $_POST['notes'];
  22. $attn = $_POST['attn'];
  23.  
  24.  
  25. if (eregi('http:', $notes)) {
  26. die ("Do NOT try that! ! ");
  27. }
  28. if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
  29. {
  30. echo "<h2>Use Back - Enter valid e-mail</h2>\n";
  31. $badinput = "<h2>Feedback was NOT submitted</h2>\n";
  32. echo $badinput;
  33. die ("Go back! ! ");
  34. }
  35.  
  36. if(empty($visitor) || empty($visitormail) || empty($notes )) {
  37. echo "<h2>Use Back - fill in all fields</h2>\n";
  38. die ("Use back! ! ");
  39. }
  40.  
  41. if(isset($_POST["sendmail"]) && trim($_POST["sendmail"])!=='') {
  42.  
  43. $todayis = date("l, F j, Y, g:i a") ;
  44.  
  45. $attn = $attn ;
  46. $subject = $attn;
  47.  
  48. $notes = stripcslashes($notes);
  49.  
  50. $message = " $todayis [EST] \n
  51. Attention: $attn \n
  52. Message: $notes \n
  53. From: $visitor ($visitormail)\n
  54. Additional Info : IP = $ip \n
  55. Browser Info: $httpagent \n
  56. Referral : $httpref \n
  57. ";
  58.  
  59. $from = "From: $visitormail\r\n";
  60.  
  61.  
  62. mail("test1@myemail.com", $subject, $message, $from)
  63.  
  64.  
  65. else if(isset($_POST["sendmail2"]) && trim($_POST["sendmail2"])!=='') {
  66. $todayis = date("l, F j, Y, g:i a") ;
  67.  
  68. $attn = $attn ;
  69. $subject = $attn;
  70.  
  71. $notes = stripcslashes($notes);
  72.  
  73. $message = " $todayis [EST] \n
  74. Attention: $attn \n
  75. Message: $notes \n
  76. From: $visitor ($visitormail)\n
  77. Additional Info : IP = $ip \n
  78. Browser Info: $httpagent \n
  79. Referral : $httpref \n
  80. ";
  81.  
  82. $from = "From: $visitormail\r\n";
  83.  
  84.  
  85. mail("test2@myemail.com", $subject, $message, $from)}
  86.  
  87. ?>
  88. </body>
  89. </html>
  90.  
If I am missing something? Thanks in advance!
Sep 17 '09 #1
4 1871
TheServant
1,168 Recognized Expert Top Contributor
Main reason:
You have not closed your if statement with curly brackets. Should be like:
Expand|Select|Wrap|Line Numbers
  1. if (x=1) {
  2. //do something
  3. }
  4. elseif (x=2) {
  5. //do something else
  6. }
  7. else {
  8. //do yet another thing
  9. }
Hope that helps. Welcome to Bytes.
Sep 17 '09 #2
Atli
5,058 Recognized Expert Expert
Hey. Welcome to Bytes!

I see 2 errors there.

On lines #62 and #85 you are missing the semi-colon (;) to end the line.

And, before the "else if " on line #65, you are missing the } to close the if preceding it.

An if structure should look like:
Expand|Select|Wrap|Line Numbers
  1. if {
  2.   // statementes
  3. }
  4. else if {
  5.   // statements
  6. }
Yours is like this:
Expand|Select|Wrap|Line Numbers
  1. if {
  2.   // statementes
  3. else if {
  4.   // statements
  5. }
Sep 17 '09 #3
Atli
5,058 Recognized Expert Expert
@TheServant
Actually, both work in the typical curly-braces structure.
(See elseif/else if - PHP manual)
Sep 17 '09 #4
TheServant
1,168 Recognized Expert Top Contributor
@Atli
Point taken. Thanks. And well done with the ";" pick-up ;)
Sep 17 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4115
by: Steven | last post by:
I got a "Parse error: parse error in ..." in this line: if(empty($_POST){ ..... But if I fist assign $ssn=$_POST; and then if(empty($ssn){ ... it is working. Any advice? Thanks in advance.
1
2513
by: H.L Bai | last post by:
hi, everybody i meet a parse error when i used the xml4c. any proposal is helpful. The error is following .../XMLRegionHandler.h:59 parse error before '*' .../XMLRegionHandler.h:60 parse error before '*'
2
4997
by: Vittal | last post by:
Hello All, I am trying to compile my application on Red Hat Linux 8 against gcc 3.2.2. Very first file in application is failing to compile. I tried compiling my application on Linux 7.2 against gcc 3.1 and it got build without any problems. However on against gcc 3.2.2 I hitting this error:
21
2946
by: BWIGLEY | last post by:
Basically I've just started making a game. So far it makes an array 25 by 20 and tries to make five rooms within it. In scr_make_room() there's parse errors: 20 C:\c\Rooms\Untitled1.c parse error before "top_x" 28 C:\c\Rooms\Untitled1.c parse error before "first_square_x" 35 C:\c\Rooms\Untitled1.c parse error before '}' token Why are these happening? int room_square, selected = 1, squares = 1, first_square_x
6
8624
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar circumstances(XML file source) and with exactly the same value it gets it perfectly correct all the time. These are the results I got, XML is always correct, CSV are only incorrect for some of the values (above about 0.01) but always gives the...
5
64662
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
1
64242
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
1
3757
by: Phaelle | last post by:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' What does that error mean? I can´t find the mistake!! In another script, I have got another kind of mistake : parse error: parse error at .. line (and it is always on the last line!) Thanks for your help Raphaelle
2
3232
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString", $formName); // 06-22-07 - the next commands try to import all the functions that the
5
2713
by: goldtech | last post by:
SAX XML Parse Python error message Hi, My first attempt at SAX, but have an error message I need help with. I cite the error message, code, and xml below. Be grateful if anyone can tell me what the fix is. Thanks.
0
9686
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10890
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10279
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9416
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7819
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5855
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3127
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.