webgyrl Posted May 6, 2007 Posted May 6, 2007 Hi all! I have been having a terribly trying time with a script I am trying to modify for a Joomla Component called AKO Comment. Basically this component allows for comments to be made on articles on the site and an alert with the comment content is sent to the admin address listed in the back end. The original block of code for this script for emails being sent to Admin is as follows: ># Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME.': '.$acname; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL.': <a href="mailto:'.$email.'">'.$email.'</a>'; if ($web != '') $acmailtext .= 'Web: <a href="'.$web.'">'.$web.'</a>'; $acmailtext .= _AKOCOMMENT_ENTERTITLE . $title; $acmailtext .= _AKOCOMMENT_ENTERTEXT . $comment; $acmailtext .= $rowTitle ; $acmailtext .= '<a href="' . $articlelink.'">' . $articlelink . '</a>\n'; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers = 'MIME-Version: 1.0' . '\n'; //$headers .= 'Content-type: text/html; charset=iso-8859-1' . '\n'; $headers .= 'Content-type: text/plain; ' . _ISO . '\n'; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,$acmailtext,$headers); } I want to strip out ALL the HTML formatting for the alert notices for the comments and comment reporting so that only a plain text email is sent. Each line of data sent should have a space in between, so the comments and data are not all squished together. The developer just told me to change everything in the Admin Email section of the script from 'Content-type: text/html; ' to 'Content-type: text/plain; ' I did this, but it did not work. I got all the HTML junk in the body of the email and it looks a mess! Then he said something about taking out all the HTML tags, so I did that but I keep getting a parsing error that says: Parse error: parse error, unexpected '.' in /home/content/r/e/c/xxxxxxxxx/html/components/com_akocomment/akocomment.php on line 164 So I have been fiddling and nothing is working. I am assuming by the error that there is some unexpected period somewhere. When I change one period I get another parsing error and then I got some other strange errors also. What I have right now is the following: ># Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME .$acname. "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL .$email. "\n"; if ($web != '') $acmailtext .= $web "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE . $title "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT . $comment"\n"; $acmailtext .= .$rowTitle. "\n"; $acmailtext .= .$articlelink. "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers = 'MIME-Version: 1.0' . "\n"; //$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\n"; $headers .= 'Content-type: text/plain; ' . _ISO . "\n"; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,$acmailtext,$headers); } With this in place I am getting this error: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/r/e/c/xxxxxxxxxxx/html/components/com_akocomment/akocomment.php on line 166 I'll be honest, at this point I've spent 5 hours fiddling and farting around with no luck. I tried to read the PHP docs, but they are like greek to me as I am not a programmer and have very, very limited ability to work with PHP. I don't have time to learn a whole programming language as I very rarely modify scripts at all. Can anyone point out my error here in this attempt to just get plain text emails? The developer does not have a lot of time to help me. This is an open source component, so there is not much support. His forums have hardly anyone on them and I've asked this question to some Joomla people I know with no answer. If someone could help out, I would really appreciate it. I'm going NUTS! Thanks! Quote
carbonize Posted May 6, 2007 Posted May 6, 2007 (edited) Simplest way would of just been to use >$acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); I stripped most headers as your from address is the only header you need as emails are sent plaintext by default. The strip_tags function will strip all the HTML from the message for you. Edited May 6, 2007 by carbonize Quote
webgyrl Posted May 6, 2007 Author Posted May 6, 2007 (edited) Simplest way would of just been to use >$acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); I stripped most headers as your from address is the only header you need as emails are sent plaintext by default. The strip_tags function will strip all the HTML from the message for you. Carbonize! Wow! Thank you. So I should use those two lines where in that block of code? And will the lines come in with spaces in between them? I don't want it all smushed together if that is possible. I'm sorry if this sounds stupid, I really have no clue when it comes to PHP. Thank you so much. Edited May 6, 2007 by webgyrl Quote
carbonize Posted May 6, 2007 Posted May 6, 2007 I left >$acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; in to show from where to replace the code. The code adds new line markers to the message body so it should be on different lines. If not come back and we can work on that. Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 (edited) I left >$acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; in to show from where to replace the code. The code adds new line markers to the message body so it should be on different lines. If not come back and we can work on that. Hi Carbonize... OK this is what I replaced the Admin block of code with ># Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME .$acname. "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL .$email. "\n"; if ($web != '') $acmailtext .= $web "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE . $title "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT . $comment"\n"; $acmailtext .= .$rowTitle. "\n"; $acmailtext .= .$articlelink. "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); } I got this error when trying to add a coment: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/r/e/c/xxxxxxxxxxx/html/components/com_akocomment/akocomment.php on line 166 I am sure I must have done something wrong! Line 166 is: > if ($web != '') $acmailtext .= $web "\n"; Should there be periods around the $web? I have no clue! Thank you so much for your help. I've been messing with this for 2 weeks with no progress! Edited May 7, 2007 by webgyrl Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 (edited) Ok so I thought maybe there were some missing periods, so I changed the places where there was only one period in front of a variable to a period before and after with no space. So the code looks like: ># Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME .$acname. "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL .$email. "\n"; if ($web != '') $acmailtext .= .$web. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE .$title. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT .$comment. "\n"; $acmailtext .= .$rowTitle. "\n"; $acmailtext .= .$articlelink. "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); } I get this error: Parse error: parse error, unexpected '.' in /home/content/r/e/c/xxxxxxxxx/html/components/com_akocomment/akocomment.php on line 166 So now there is some extra period in line 166. From the reading I've done these errors may not even be reflecting the right line? Is that true? Like the error may say line 166, but in fact it's 168 or 164 or something? I think I will stop fiddling and wait to hear back from you Carbonize. I don't want to butcher the code any more than I have! LOL Thanks! Edited May 7, 2007 by webgyrl Quote
TCH-Don Posted May 7, 2007 Posted May 7, 2007 I think the problem is you have a period before $web that should not be there. try >if ($web != '') $acmailtext .= $web . "\n"; the .= means add to the contents of the string $acmailtext and the period after means add together as in $web plus "\n" Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 (edited) I think the problem is you have a period before $web that should not be there. try >if ($web != '') $acmailtext .= $web . "\n"; the .= means add to the contents of the string $acmailtext and the period after means add together as in $web plus "\n" Hi Don! Hugs! OK I took out the period before the equals sign. ># Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME .$acname. "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL .$email. "\n"; if ($web != '') $acmailtext = .$web. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE .$title. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT .$comment. "\n"; $acmailtext .= .$rowTitle. "\n"; $acmailtext .= .$articlelink. "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); } I got this error: Parse error: parse error, unexpected '.' in /home/content/r/e/c/xxxxxxxxxxxxx/html/components/com_akocomment/akocomment.php on line 166 I am going to try taking out the periods before and after $web Will post back with results. Edited May 7, 2007 by webgyrl Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 Drats! That didn't work either. ># Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME .$acname. "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL .$email. "\n"; if ($web != '') $acmailtext = $web "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE .$title. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT .$comment. "\n"; $acmailtext .= .$rowTitle. "\n"; $acmailtext .= .$articlelink. "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); } I got this error: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/r/e/c/xxxxxxxx/html/components/com_akocomment/akocomment.php on line 166 Any ideas? Quote
TCH-Don Posted May 7, 2007 Posted May 7, 2007 leave the .= as is you had period . just before $web, remove it original if ($web != '') $acmailtext .= .$web. "\n"; new if ($web != '') $acmailtext .= $web . "\n"; Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 leave the .= as isyou had period . just before $web, remove it original if ($web != '') $acmailtext .= .$web. "\n"; new if ($web != '') $acmailtext .= $web . "\n"; Ah OK. So then I assume I should to that for the rest of the lines of code then? Correct? Quote
TCH-Don Posted May 7, 2007 Posted May 7, 2007 $acmailtext .= .$rowTitle. "\n"; $acmailtext .= .$articlelink. "\n"; Yep, I did not look at those lines I am not going to say the script wll work, but those are errors. Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 $acmailtext .= .$rowTitle. "\n"; $acmailtext .= .$articlelink. "\n"; Yep, I did not look at those lines I am not going to say the script wll work, but those are errors. OK I am going to take out all the periods before the variables and then see what happens. Thank you Don! Will let you know what happens! Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 Alright... I changed all the code to this: > # Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME $acname. "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL $email. "\n"; if ($web != '') $acmailtext .= $web "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE $title. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT $comment. "\n"; $acmailtext .= $rowTitle. "\n"; $acmailtext .= $articlelink. "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); } This is the error I am getting now: Parse error: parse error, unexpected T_VARIABLE in /home/content/r/e/c/xxxxxxxx/html/components/com_akocomment/akocomment.php on line 164 According to Dreamweaver code view, like 164 is: >$acmailtext .= _AKOCOMMENT_ENTERNAME $acname. "\n"; Obviously there is something in the syntax that is wrong... but I can't figure out what it might be! All I did was take out the periods before the variables. LOL Joy of joys! But I feel we are getting somewhere! Quote
TCH-Don Posted May 7, 2007 Posted May 7, 2007 $acmailtext .= _AKOCOMMENT_ENTERNAME $acname. "\n"; try $acmailtext .= _AKOCOMMENT_ENTERNAME . $acname . "\n"; Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 $acmailtext .= _AKOCOMMENT_ENTERNAME $acname. "\n";try $acmailtext .= _AKOCOMMENT_ENTERNAME . $acname . "\n"; New code block: > # Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='.$contentid.'&Itemid='.$acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME . $acname . "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL $email. "\n"; if ($web != '') $acmailtext .= $web. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE $title. "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT $comment. "\n"; $acmailtext .= $rowTitle. "\n"; $acmailtext .= $articlelink. "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); } I got this error: Parse error: parse error, unexpected T_VARIABLE in /home/content/r/e/c/xxxxxxxxxxx/html/components/com_akocomment/akocomment.php on line 165 Is there supposed to be 1 space between the end of the variable name and the period? Line 165 is: > if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL $email. "\n"; Quote
TCH-Don Posted May 7, 2007 Posted May 7, 2007 change if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL $email. "\n"; to if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL . $email. "\n"; yes you need a space between the strings and the period think of it as $string plus $string or $string . $string Sorry, I am at work and can't seem to concentrate. Have to go good luck. Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 changeif ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL $email. "\n"; to if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL . $email. "\n"; yes you need a space between the strings and the period think of it as $string plus $string or $string . $string Sorry, I am at work and can't seem to concentrate. Have to go good luck. Ah OK Don. I will fiddle. Thank you so much for the help! Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 (edited) I think I'm just hopeless at this! I remove a period, I get an error, I put a period back in, I get an error. I tried this: > $acmailtext .= _AKOCOMMENT_ENTERTITLE $title "\n"; Doesn't work... still get: Parse error: parse error, unexpected T_VARIABLE in /home/content/r/e/c/xxxxxxx/html/components/com_akocomment/akocomment.php on line 167 I think I have to take a break and clear my head for a bit. I suck at this! LOL Edited May 7, 2007 by webgyrl Quote
TCH-Don Posted May 7, 2007 Posted May 7, 2007 Here is your code with the spaces between the strings and the period. ># Send out admin mail if ($ac_notify && is_email($ac_notify_email) ) { $query1 = ("SELECT title FROM #__content WHERE id='$contentid'"); $database->setQuery( $query1 ); $rowTitle = $database->loadResult(); $articlelink = sefRelToAbs($mosConfig_live_site.'/index.php?option=com_content&task=view&id='. $contentid . '&Itemid=' . $acitemid); $acmailtext = _AKOCOMMENT_ADMINMAIL; $acmailtext .= _AKOCOMMENT_ENTERNAME . $acname . "\n"; if ($email != '') $acmailtext .= _AKOCOMMENT_ENTERMAIL . $email . "\n"; if ($web != '') $acmailtext .= $web . "\n"; $acmailtext .= _AKOCOMMENT_ENTERTITLE . $title . "\n"; $acmailtext .= _AKOCOMMENT_ENTERTEXT . $comment . "\n"; $acmailtext .= $rowTitle . "\n"; $acmailtext .= $articlelink . "\n"; $acmailtext .= _AKOCOMMENT_ADMINMAILFOOTER; $headers .= 'From: ' . $ac_notify_email; mail($ac_notify_email,_AKOCOMMENT_ADMINMAILHEADER,strip_tags($acmailtext),$headers); } The period "." is used to add two strings together, or more technically, the period is the concatenation operator for strings. The spaces are not always needed but its good coding and can prevent mistakes. A good web site to learn a little about PHP is Tizag.com Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 Don! This worked. I got: Hello Admin, A a user has posted a new comment to a content item at http://www.xxxxxxxxxx.com: Name:Test E-mailtest2@test.com http://www.test.com Title:Test2 Comment:This is another test to see if this really works. This is just a test. Love Is http://www.xxxxxxxxxxx.com/index.php?optio...5&Itemid=26 Please do not respond to this message as it is automatically generated and is for information purposes only. Now my only question would be how to get spaces after the colons : But I will fiddle. I can't tell you how much I appreciate the help. I went to a few sites to learn PHP, but they honestly scared me to death! LOL I am gonna try the site you suggested. Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 I got it! I changed some things in the language file and also added in another space before the article title in the PHP code. Hello Admin, A a user has posted a new comment to a content item at http://www.xxxxxxxxxxx.com: Name: Test 5 E-mail: test5@test.com http://www.test.com Title: test 5 Comment: Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla faci Love Is http://www.xxxxxxxxxxx.com/index.php?optio...5&Itemid=26 Please do not respond to this message as it is automatically generated and is for information purposes only. Wow, I am so happy! I also learned a lot. But I'd never have learned about this without your help Carbonize and Don. Thank you SO much! Quote
webgyrl Posted May 7, 2007 Author Posted May 7, 2007 This was the only cookie I could find... for the hard working men... LOL Thank you sirs! Quote
carbonize Posted May 7, 2007 Posted May 7, 2007 I would of helped more but I was afk for all of last night. Glad Don got there in the end Quote
TCH-Don Posted May 7, 2007 Posted May 7, 2007 Glad its working. Thats why we say we are family here. Quote
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.