Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17299 > unrolled thread

New line in php not working

Started bywart2ww <fcc@bmi.net>
First post2017-01-28 18:24 -0800
Last post2022-06-30 07:42 -0700
Articles 11 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  New line in php not working wart2ww <fcc@bmi.net> - 2017-01-28 18:24 -0800
    Re: New line in php not working "J.O. Aho" <user@example.net> - 2017-01-29 09:30 +0100
      Re: New line in php not working Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-29 15:10 +0100
        Re: New line in php not working wart2ww <fcc@bmi.net> - 2017-01-29 18:02 -0800
        Re: New line in php not working wart2ww <fcc@bmi.net> - 2017-01-29 18:04 -0800
    Re: New line in php not working Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-29 21:14 -0500
      Re: New line in php not working wart2ww <fcc@bmi.net> - 2017-01-29 18:56 -0800
        Re: New line in php not working Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-29 22:08 -0500
          Re: New line in php not working wart2ww <fcc@bmi.net> - 2017-01-29 19:40 -0800
            Re: New line in php not working Jerry Stuckle <jstucklex@attglobal.net> - 2017-01-30 07:41 -0500
    Re: New line in php not working Angel <he1983912@gmail.com> - 2022-06-30 07:42 -0700

#17299 — New line in php not working

Fromwart2ww <fcc@bmi.net>
Date2017-01-28 18:24 -0800
SubjectNew line in php not working
Message-ID<0157ce84-974d-407e-9a25-c66e8ceba904@googlegroups.com>
The following code all works fine in a <?php  ?> block except the \n is not working. All the fields in the in the email are on one line. I have done this before and it seemed to work but not now. What have I done wrong?

foreach ($_POST as $key => $value) { 
                 
 if (isset($fields[$key])) { 
        $emailText .= "$fields[$key]: $value\n"; } 
} 

Thank you for your help. 

[toc] | [next] | [standalone]


#17301

From"J.O. Aho" <user@example.net>
Date2017-01-29 09:30 +0100
Message-ID<ef5ngdFu924U1@mid.individual.net>
In reply to#17299
On 01/29/17 03:24, wart2ww wrote:
> The following code all works fine in a <?php  ?> block except the \n is not working.
> All the fields in the in the email are on one line.

This has nothing to do with "\n" not working, this is the way the mail
client handles the "\n", for example the terrible mail client outlook
will show all in one line, you will need to have "\t\n\n" for it to
handle this correctly, while the nice Thunderbird will show it as
intended as it is with "\n".


> I have done this before and it seemed to work but not now. What have I done wrong?
> 
> foreach ($_POST as $key => $value) { 
>                  
>  if (isset($fields[$key])) { 
>         $emailText .= "$fields[$key]: $value\n"; } 
> } 

For more readability of your code, you should stick with a coding
standard and make variables in a string to stand out


foreach ($_POST as $key => $value) {

  if (isset($fields[$key])) {
         $emailText .= "${fields[$key]}: ${value}\n";
  }
}

or



foreach ($_POST as $key => $value) {

if (isset($fields[$key])) {
$emailText .= $fields[$key] .": ". $value ."\n";
}
}


> Thank you for your help. 


np.

-- 

 //Aho

[toc] | [prev] | [next] | [standalone]


#17306

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-01-29 15:10 +0100
Message-ID<4262223.31r3eYUQgx@PointedEars.de>
In reply to#17301
J.O. Aho wrote:

> On 01/29/17 03:24, wart2ww wrote:
>> The following code all works fine in a <?php  ?> block except the \n is
>> not working. All the fields in the in the email are on one line.
> 
> This has nothing to do with "\n" not working, this is the way the mail
> client handles the "\n",

Utter nonsense.  Obviously this code is generating *header fields*.  They 
are to be separated by CRLF and nothing else.

But then again, what kind of an understanding of Internet standards can one 
expect from a person who, despite several hints, keeps abusing dedicated 
Internet domains?

-- 
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#17308

Fromwart2ww <fcc@bmi.net>
Date2017-01-29 18:02 -0800
Message-ID<8523196d-76df-4e3e-82bc-b94af49fba1e@googlegroups.com>
In reply to#17306
On Sunday, January 29, 2017 at 6:10:24 AM UTC-8, Thomas 'PointedEars' Lahn wrote:
> J.O. Aho wrote:
> 
> > On 01/29/17 03:24, wart2ww wrote:
> >> The following code all works fine in a <?php  ?> block except the \n is
> >> not working. All the fields in the in the email are on one line.
> > 
> > This has nothing to do with "\n" not working, this is the way the mail
> > client handles the "\n",
> 
> Utter nonsense.  Obviously this code is generating *header fields*.  They 
> are to be separated by CRLF and nothing else.
> 
> But then again, what kind of an understanding of Internet standards can one 
> expect from a person who, despite several hints, keeps abusing dedicated 
> Internet domains?
> 
> -- 
> PointedEars
> Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#17309

Fromwart2ww <fcc@bmi.net>
Date2017-01-29 18:04 -0800
Message-ID<b6910a46-a6d4-4388-bdc0-1d663bb770b4@googlegroups.com>
In reply to#17306
On Sunday, January 29, 2017 at 6:10:24 AM UTC-8, Thomas 'PointedEars' Lahn wrote:
> J.O. Aho wrote:
> 
> > On 01/29/17 03:24, wart2ww wrote:
> >> The following code all works fine in a <?php  ?> block except the \n is
> >> not working. All the fields in the in the email are on one line.
> > 
> > This has nothing to do with "\n" not working, this is the way the mail
> > client handles the "\n",
> 
> Utter nonsense.  Obviously this code is generating *header fields*.  They 
> are to be separated by CRLF and nothing else.
> 
> But then again, what kind of an understanding of Internet standards can one 
> expect from a person who, despite several hints, keeps abusing dedicated 
> Internet domains?
> 
> -- 
> PointedEars
> Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

I have a question about your response. When you talk about 'keeps abusing dedicated Internet domains are you referring to me, the author of the original post? I am not sure which one of us you are chastising.

[toc] | [prev] | [next] | [standalone]


#17310

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-29 21:14 -0500
Message-ID<o6m7em$kgm$1@jstuckle.eternal-september.org>
In reply to#17299
On 1/28/2017 9:24 PM, wart2ww wrote:
> The following code all works fine in a <?php  ?> block except the \n is not working. All the fields in the in the email are on one line. I have done this before and it seemed to work but not now. What have I done wrong?
> 
> foreach ($_POST as $key => $value) { 
>                  
>  if (isset($fields[$key])) { 
>         $emailText .= "$fields[$key]: $value\n"; } 
> } 
> 
> Thank you for your help. 
> 

OK, I may have screwed up here.  I thought you were talking about the
body of the message.  Are these header fields you are setting?  If so, I
agree with the others - if you're using Linux, you need to use \r\n.
(If you're on Windows, \n should already equate to \r\n).

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17311

Fromwart2ww <fcc@bmi.net>
Date2017-01-29 18:56 -0800
Message-ID<0c089e0c-55df-481f-906b-c58f8186134a@googlegroups.com>
In reply to#17310
On Sunday, January 29, 2017 at 6:14:26 PM UTC-8, Jerry Stuckle wrote:
> On 1/28/2017 9:24 PM, wart2ww wrote:
> > The following code all works fine in a <?php  ?> block except the \n is not working. All the fields in the in the email are on one line. I have done this before and it seemed to work but not now. What have I done wrong?
> > 
> > foreach ($_POST as $key => $value) { 
> >                  
> >  if (isset($fields[$key])) { 
> >         $emailText .= "$fields[$key]: $value\n"; } 
> > } 
> > 
> > Thank you for your help. 
> > 
> 
> OK, I may have screwed up here.  I thought you were talking about the
> body of the message.  Are these header fields you are setting?  If so, I
> agree with the others - if you're using Linux, you need to use \r\n.
> (If you're on Windows, \n should already equate to \r\n).
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

The code is for a confirmation email message after a form is submitted. It is designed for Windows environment.

[toc] | [prev] | [next] | [standalone]


#17312

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-29 22:08 -0500
Message-ID<o6mak4$ko8$1@jstuckle.eternal-september.org>
In reply to#17311
On 1/29/2017 9:56 PM, wart2ww wrote:
> On Sunday, January 29, 2017 at 6:14:26 PM UTC-8, Jerry Stuckle wrote:
>> On 1/28/2017 9:24 PM, wart2ww wrote:
>>> The following code all works fine in a <?php  ?> block except the \n is not working. All the fields in the in the email are on one line. I have done this before and it seemed to work but not now. What have I done wrong?
>>>
>>> foreach ($_POST as $key => $value) { 
>>>                  
>>>  if (isset($fields[$key])) { 
>>>         $emailText .= "$fields[$key]: $value\n"; } 
>>> } 
>>>
>>> Thank you for your help. 
>>>
>>
>> OK, I may have screwed up here.  I thought you were talking about the
>> body of the message.  Are these header fields you are setting?  If so, I
>> agree with the others - if you're using Linux, you need to use \r\n.
>> (If you're on Windows, \n should already equate to \r\n).
>>
> 
> The code is for a confirmation email message after a form is submitted. It is designed for Windows environment.
> 

If you're running on Windows, then "\n" should already be converted to
crlf ("\r\n" in Linux).  But I'm still not sure if you're in the header
or the body of the message.

Also, what is the message encoding?  Is it plain text, html, or what?

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17313

Fromwart2ww <fcc@bmi.net>
Date2017-01-29 19:40 -0800
Message-ID<7e3defc9-0d60-4059-b98c-a2bdea2f2a26@googlegroups.com>
In reply to#17312
On Sunday, January 29, 2017 at 7:08:30 PM UTC-8, Jerry Stuckle wrote:
> On 1/29/2017 9:56 PM, wart2ww wrote:
> > On Sunday, January 29, 2017 at 6:14:26 PM UTC-8, Jerry Stuckle wrote:
> >> On 1/28/2017 9:24 PM, wart2ww wrote:
> >>> The following code all works fine in a <?php  ?> block except the \n is not working. All the fields in the in the email are on one line. I have done this before and it seemed to work but not now. What have I done wrong?
> >>>
> >>> foreach ($_POST as $key => $value) { 
> >>>                  
> >>>  if (isset($fields[$key])) { 
> >>>         $emailText .= "$fields[$key]: $value\n"; } 
> >>> } 
> >>>
> >>> Thank you for your help. 
> >>>
> >>
> >> OK, I may have screwed up here.  I thought you were talking about the
> >> body of the message.  Are these header fields you are setting?  If so, I
> >> agree with the others - if you're using Linux, you need to use \r\n.
> >> (If you're on Windows, \n should already equate to \r\n).
> >>
> > 
> > The code is for a confirmation email message after a form is submitted. It is designed for Windows environment.
> > 
> 
> If you're running on Windows, then "\n" should already be converted to
> crlf ("\r\n" in Linux).  But I'm still not sure if you're in the header
> or the body of the message.
> 
> Also, what is the message encoding?  Is it plain text, html, or what?
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

The code is written and saved as a php extension. The  code is written as html in the body, not the header.

[toc] | [prev] | [next] | [standalone]


#17316

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-01-30 07:41 -0500
Message-ID<o6nc5t$nll$1@jstuckle.eternal-september.org>
In reply to#17313
On 1/29/2017 10:40 PM, wart2ww wrote:
> On Sunday, January 29, 2017 at 7:08:30 PM UTC-8, Jerry Stuckle wrote:
>> On 1/29/2017 9:56 PM, wart2ww wrote:
>>> On Sunday, January 29, 2017 at 6:14:26 PM UTC-8, Jerry Stuckle wrote:
>>>> On 1/28/2017 9:24 PM, wart2ww wrote:
>>>>> The following code all works fine in a <?php  ?> block except the \n is not working. All the fields in the in the email are on one line. I have done this before and it seemed to work but not now. What have I done wrong?
>>>>>
>>>>> foreach ($_POST as $key => $value) { 
>>>>>                  
>>>>>  if (isset($fields[$key])) { 
>>>>>         $emailText .= "$fields[$key]: $value\n"; } 
>>>>> } 
>>>>>
>>>>> Thank you for your help. 
>>>>>
>>>>
>>>> OK, I may have screwed up here.  I thought you were talking about the
>>>> body of the message.  Are these header fields you are setting?  If so, I
>>>> agree with the others - if you're using Linux, you need to use \r\n.
>>>> (If you're on Windows, \n should already equate to \r\n).
>>>>
>>>
>>> The code is for a confirmation email message after a form is submitted. It is designed for Windows environment.
>>>
>>
>> If you're running on Windows, then "\n" should already be converted to
>> crlf ("\r\n" in Linux).  But I'm still not sure if you're in the header
>> or the body of the message.
>>
>> Also, what is the message encoding?  Is it plain text, html, or what?
>>
>> -- 
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> jstucklex@attglobal.net
>> ==================
> 
> The code is written and saved as a php extension. The  code is written as html in the body, not the header.
> 

Ah, this is written as HTML - that is a key factor here.  HTML ignores
white space in email, just as it does on a web page.  Look at the source
of your email - you will see the line break there.

If you want a break in HTML, you have to use an HTML code for it, i.e.
<br> for a line break or <p>...</p> for a paragraph break.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#19011

FromAngel <he1983912@gmail.com>
Date2022-06-30 07:42 -0700
Message-ID<a9026258-5f04-47d9-946d-8bff3017a419n@googlegroups.com>
In reply to#17299
Reprogram then php, so that it will work.


******************************
Angel
☏ ------> 372 53900660


wart2ww kirjutas Pühapäev, 29. jaanuar 2017 kl 04:24:42 UTC+2:
> The following code all works fine in a <?php ?> block except the \n is not working. All the fields in the in the email are on one line. I have done this before and it seemed to work but not now. What have I done wrong? 
> 
> foreach ($_POST as $key => $value) { 
> 
> if (isset($fields[$key])) { 
> $emailText .= "$fields[$key]: $value\n"; } 
> } 
> 
> Thank you for your help.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web