Chezshire Posted June 16, 2009 Share Posted June 16, 2009 Hello everyone, I've tried a few things and whatever is causing my error is just starring me right in the face and I'm just not seeing it. I've played around with the double and single quotes, checked the line terminations, etc. And from what I can tell my code shoudl work but it does I'm trying to cause the fields which are 'optional' (thread/post & Character(s)) to be not print/echo in the e-mail that is produced if their they are left empty. The following code results in the following error: Parse error: parse error, unexpected T_VARIABLE in /home/content/z/a/n/zanland/html/xpg/modMail/report2.php on line 24. This is line #24: $msg .= (empty($other)) ? "" : 'ISSUE, COMMENT OR CONCERN: $other \n \n'; Full code is as follows: <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>XPG » Message Confirmed!</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h2>XPG » Message Sent!</h2> <?php $name = $_POST['namePlayer']; $topic = $_POST['nameTopic']; $other = $_POST['other']; $thread_PostID = $_POST['threadPostID']; $email = $_POST['email']; $name_char = $_POST['nameChar']; $to = 'BYRNE <mercurypagen@yahoo.com>, DITKO <chezshire@gmail.com>, LIEFIELD <babsbatgirlfan@yahoo.com>, MILLER <spasmolytica@yahoo.com>, Silvestri<rogue_kiss@yahoo.com>, SIMONSON <vismaior2000@yahoo.com>, WHEDON <scottebarr@optonline.net>, WOLFMAN <ghoogler@gmail.com>'; $subject = 'XPG » ' . $topic .' '; $msg = 'FROM: $name \n \n'; $msg .= (empty($other)) ? "" : 'ISSUE, COMMENT OR CONCERN: $other \n \n'; $msg .= (empty($thread_PostID)) ? "" : 'THREAD/POST: $thread_PostID \n \n'; $msg .= 'CHARACTER(S): $name_char \n \n'; echo 'Thank you for contacting us ' . $name . ' regarding ' . $topic . '. <br /><br /> We will discuss this subject and try to have one of XPG’s Staff member contact you regarding this issue within 24 hours. If you have sent a notice that you will be away, this will be done ASAP and you have up to two weeks excused abscence.<br /> Thank you for your patience and understanding while you wait for us to get back to you. <br /> <br />'; ?> <p align=center><a href=../messages.php>RETURN TO XPG</a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/ Share on other sites More sharing options...
Alex Posted June 16, 2009 Share Posted June 16, 2009 There isn't an error on that line: $msg .= (empty($other)) ? "" : 'ISSUE, COMMENT OR CONCERN: $other \n \n'; Besides the fact that if you use single quotes your variable $other won't be parsed: Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857510 Share on other sites More sharing options...
Chezshire Posted June 16, 2009 Author Share Posted June 16, 2009 Hello AlexWD, I'm not sure if your being very clever and making a funny or trying to help me out. I'm still new to all of this. I'm starting college this fall and one of my first classes is going to be a PHP intro, etc. Right now I'm just trying to get my little dumb form to work a little better then it does - I think you're saying that line 24 looks ok as it, which would mean there is a problem earlier in the form then (yes?). I've looked through the whole thing and have not been able to find it. Can you help and if so can you say it in a manner a novice such as myself would understand? Thank you for looking - it is appreciated. -Chex Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857540 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 He's saying if $other is NOT empty it will concatenate $msg with 'ISSUE, COMMENT OR CONCERN: $other \n \n'; (literally the characters $other). You need to change the single quotes around that condition to double quotes. If you test out both ways you will see the difference. Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857542 Share on other sites More sharing options...
Chezshire Posted June 16, 2009 Author Share Posted June 16, 2009 Thank you Maq I wasn't able to follow what AlexWD said as I'm just not on his level yet (or yours) but i hope to be one day. Thank you - I'm off to work those quotes (i did try changing them all from single to double but not specific parts to single to double as you/he are suggesting. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857565 Share on other sites More sharing options...
Alex Posted June 16, 2009 Share Posted June 16, 2009 That shouldn't be causing your errors. I didn't see anything that should. It's just that if you have a variable within single quotes, it won't output the variables value. It'll evaluate it like a string. $variable = 'Some value'; echo "This variable has the value of $variable"; //Some value echo 'This variable has the value of $variable'; //$variable Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857573 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 That shouldn't be causing your errors. I didn't see anything that should. It's just that if you have a variable within single quotes, it won't output the variables value. It'll evaluate it like a string. $variable = 'Some value'; echo "This variable has the value of $variable"; //Some value echo 'This variable has the value of $variable'; //$variable I agree. Nothing there should cause an error, even with error_reporting set to max. There are like 5 other lines that need to be changed from single to double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857587 Share on other sites More sharing options...
Chezshire Posted June 16, 2009 Author Share Posted June 16, 2009 Hmms. I fear that I'm not understanding ( Makes a sad dumb face ) I tried what I though you quys were suggesting (see example #1), and got an error - so i deleted lines 24, 25 and 26 to see what would happen and the page worked in that there were no errors (see Example #2), but the message and content wasn't being sent as the handlers for that stuff was deleted from the code. So it seems to me that something is wrong with these three lines, what I don't know but it's what i'm trying to figure today (hopefully) #24: $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; #25: $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; #26: $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; So am i not understanding what needs to be single quoted vs. double quoted or is it that i'm trying to do isn't doable? Example 1: <?php $name = $_POST['namePlayer']; $topic = $_POST['nameTopic']; $other = $_POST['other']; $thread_PostID = $_POST['threadPostID']; $email = $_POST['email']; $name_char = $_POST['nameChar']; $to = 'BYRNE <mercurypagen@yahoo.com>, DITKO <chezshire@gmail.com>, LIEFIELD <babsbatgirlfan@yahoo.com>, MILLER <spasmolytica@yahoo.com>, Silvestri<rogue_kiss@yahoo.com>, SIMONSON <vismaior2000@yahoo.com>, WHEDON <scottebarr@optonline.net>, WOLFMAN <ghoogler@gmail.com>'; $subject = 'XPG » ' . $topic .' '; $msg = 'FROM: $name \n \n'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; echo 'Thank you for contacting us ' . $name . ' regarding ' . $topic . '. <br /><br /> We will discuss this subject and try to have one of XPG’s Staff member contact you regarding this issue within 24 hours. If you have sent a notice that you will be away, this will be done ASAP and you have up to two weeks excused abscence.<br /> Thank you for your patience and understanding while you wait for us to get back to you. <br /> <br />'; ?> Example two (no errors but the message isn't being delivered, only a notice someone sent an email which is kind of pointless): <?php $name = $_POST['namePlayer']; $topic = $_POST['nameTopic']; $other = $_POST['other']; $thread_PostID = $_POST['threadPostID']; $email = $_POST['email']; $name_char = $_POST['nameChar']; $to = 'BYRNE <mercurypagen@yahoo.com>, DITKO <chezshire@gmail.com>, LIEFIELD <babsbatgirlfan@yahoo.com>, MILLER <spasmolytica@yahoo.com>, Silvestri<rogue_kiss@yahoo.com>, SIMONSON <vismaior2000@yahoo.com>, WHEDON <scottebarr@optonline.net>, WOLFMAN <ghoogler@gmail.com>'; $subject = 'XPG » ' . $topic .' '; $msg = 'FROM: $name \n \n'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; echo 'Thank you for contacting us ' . $name . ' regarding ' . $topic . '. <br /><br /> We will discuss this subject and try to have one of XPG’s Staff member contact you regarding this issue within 24 hours. If you have sent a notice that you will be away, this will be done ASAP and you have up to two weeks excused abscence.<br /> Thank you for your patience and understanding while you wait for us to get back to you. <br /> <br />'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857593 Share on other sites More sharing options...
EchoFool Posted June 16, 2009 Share Posted June 16, 2009 <?php $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; ?> To: <?php $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: ".$other." \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: ".$thread_PostID." \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): ".$name_char." \n \n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857596 Share on other sites More sharing options...
Alex Posted June 16, 2009 Share Posted June 16, 2009 That shouldn't cause a problem. I even tested it, it worked fine: $other = 'something'; $thread_postID = 550; $name_char = 'Alex'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; Output: ISSUE, COMMENT OR CONCERN: something CHARACTER(S): Alex I even tested for a syntax error when they're all null, no errors then either. Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857597 Share on other sites More sharing options...
Maq Posted June 16, 2009 Share Posted June 16, 2009 $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; ?> To: $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: ".$other." \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: ".$thread_PostID." \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): ".$name_char." \n \n"; ?> Yes, either of those should be fine. But you changed your code from using single quotes to double now... Do you still get errors? If no, what does $msg look like when you echo it out? Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857599 Share on other sites More sharing options...
Alex Posted June 16, 2009 Share Posted June 16, 2009 Whoops, I misnamed a variable on my last example. Still there was no problems.. <?php $other = 'something'; $thread_PostID = 550; $name_char = 'Alex'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; echo $msg; ISSUE, COMMENT OR CONCERN: something THREAD/POST: 550 CHARACTER(S): Alex Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857601 Share on other sites More sharing options...
Chezshire Posted June 17, 2009 Author Share Posted June 17, 2009 Hello AlexWD & MAQ, I found one of my problems - I turned on 'See Invisibles' using TextWrangler and found that some of my character spaces had unique/special fonts in them. I deleted the special characters and test the following code (see below). I no long get the T_Variable, but I'm not not getting the e-mail either So I'm not sure what i've done now. Thoughts? Help? <?php $name = $_POST['namePlayer']; $topic = $_POST['nameTopic']; $other = $_POST['other']; $thread_PostID = $_POST['threadPostID']; $email = $_POST['email']; $name_char = $_POST['nameChar']; $to = 'BYRNE <mercurypagen@yahoo.com>, DITKO <chezshire@gmail.com>, LIEFIELD <babsbatgirlfan@yahoo.com>, MILLER <spasmolytica@yahoo.com>, Silvestri<rogue_kiss@yahoo.com>, SIMONSON <vismaior2000@yahoo.com>, WHEDON <scottebarr@optonline.net>, WOLFMAN <ghoogler@gmail.com>'; $subject = 'XPG » ' . $topic .' '; $msg = 'FROM: $name \n \n'; $msg = 'ISSUE, COMMENT OR CONCERN: $other \n \n'; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; echo 'Thank you for contacting us ' . $name . ' regarding ' . $topic . '. <br /><br /> We will discuss this subject and try to have one of XPG’s Staff member contact you regarding this issue within 24 hours. If you have sent a notice that you will be away, this will be done ASAP and you have up to two weeks excused abscence.<br /> Thank you for your patience and understanding while you wait for us to get back to you. <br /> <br />'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857605 Share on other sites More sharing options...
Alex Posted June 17, 2009 Share Posted June 17, 2009 Well first off: $msg = 'FROM: $name \n \n'; $msg = 'ISSUE, COMMENT OR CONCERN: $other \n \n'; You basically removed the FROM:, Change it to: $msg = 'FROM: $name \n \n'; $msg .= 'ISSUE, COMMENT OR CONCERN: $other \n \n'; Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857608 Share on other sites More sharing options...
Chezshire Posted June 17, 2009 Author Share Posted June 17, 2009 Thank you Alex - I'm trying that out -- I'm waiting to see if i get an e-mail or not (Crosses fingers) and is thankful for the help and guidance! Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857617 Share on other sites More sharing options...
EchoFool Posted June 17, 2009 Share Posted June 17, 2009 Is the email sending cos i dont see the mail() function in there? Otherwise hows it being sent? Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857620 Share on other sites More sharing options...
Alex Posted June 17, 2009 Share Posted June 17, 2009 Whoops, I also just noticed: It should be: $msg = "FROM: $name \n \n"; $msg .= "ISSUE, COMMENT OR CONCERN: $other \n \n"; If you're including the variable in the string you should use double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857622 Share on other sites More sharing options...
Chezshire Posted June 17, 2009 Author Share Posted June 17, 2009 It doesn't appear that the mail is being sent. Should i add the below line between lines #26 & #27? mail($to, $subject, $msg, 'From:' . $email); #26: $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; #27: thus producing the following: #26: $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; #27: mail($to, $subject, $msg, 'From:' . $email); #28: Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857626 Share on other sites More sharing options...
Chezshire Posted June 17, 2009 Author Share Posted June 17, 2009 Thank you AlexWD, MAQ and ECHOFOOL (people thanked in order of having joined this thread). You're all wonderful, I thank you from the bottom of my heart and I look forwards to when I will be able to pay your help forward or if you come to Seattle and swing by the php User Group, I'll happily buy you a cup of coffee or a beer depending on where we're meeting (hopefully it's a place that servers beer cause coffee in Seattle is obscenely expensive ) Quote Link to comment https://forums.phpfreaks.com/topic/162463-solved-vexing-t_variable-is-driving-me-nutz-help/#findComment-857634 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.