1
MS-2001
\n results in no breaks
  • 2005/7/31 16:03

  • MS-2001

  • Quite a regular

  • Posts: 204

  • Since: 2004/7/27


I've got a problem with the XOOPS Mailer. I wrote a new module and there i want to send a mail to a user if neccessary.

language\german\user.php:
define('_US_WARNMAIL', 'Hallo %s,\n\ndu wurdest soeben von "%s" verwarnt:\n\n%s\n\n Bei deiner dritten Verwarnung wirst du für eine Woche von der Community ausgelschlossen. Bei der fünten Verwarnung bleibst du für immer gebannt. Dies ist deine %s Verwarnung.\n\nMit freundlichen Grüßen\n\nDer Server');

userwarnings.php
$xoopsMailer->setBody(sprintf(_US_WARNMAIL, $thisUser->getVar("uname"), $adminUser->getVar("uname"), $warning, $xoopsDB->getRowsNum($result)));

The mail a user is getting looks like that:
Hallo User,\n\ndu wurdest soeben von "Administrator" verwarnt:\n\ntest2\n\n Bei deiner dritten Verwarnung wirst du für eine Woche von der Community ausgelschlossen. Bei der vierten Verwarnung bleibst du für immer gebannt. Dies ist deine 2 Verwarnung.\n\nMit freundlichen Grüßen\n\nDer Server

Any idea why there are no "real" breaks? I mean, i allways did it like that but there it's not working. but why?

2
Dave_L
Re: \n results in no breaks
  • 2005/7/31 16:13

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Does it work if you use "double" quotes? If you do this, note that embedded double quotes must be escaped with backslashes:

Quote:
define('_US_WARNMAIL', "Hallo %s,\n\ndu wurdest soeben von \"%s\" verwarnt:\n\n%s\n\n ... Grüßen\n\nDer Server");

3
MS-2001
Re: \n results in no breaks
  • 2005/7/31 16:18

  • MS-2001

  • Quite a regular

  • Posts: 204

  • Since: 2004/7/27


Thanks. Thats it

4
Dave_L
Re: \n results in no breaks
  • 2005/7/31 16:21

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Kewl.

The reason that fixed it is that \n is interpreted literally in a single-quoted string. In a double-quoted string, \n is translated to a newline character.

Login

Who's Online

222 user(s) are online (150 user(s) are browsing Support Forums)


Members: 0


Guests: 222


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits