Re: [PHP] new lines in textareas?
On Sat, March 29, 2008 11:26 pm, Mary Anderson wrote: I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need Do NOT set the wrap to hard It will only cause you grief in the long run. It's going to insert newlines where they shouldn't be, and then your data is corrupt. to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. If they are being quoted literally, then something is not right... \n in particular should flow through just fine. br would be quoted literally if you ran it through htmlspecialchar or htmlentities. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Sun, March 30, 2008 7:20 am, jeffry s wrote: my client ask me about this problem 2 weeks ago. he want the text to automatically go to new line after user type until the end of the line. The only possible solutions so far is using wrap='hard' or wrap='soft' eg: textarea cols=10 rows=10 wrap=hard but wrap only work on IE Netscape browser. Not working in firefox. i guess i want to use javascript to do the text formatting. trigger the javascript event every time the user using the onchange event (i never try).. i is quite complicated i dont have much time working on it. so i decided to tell him, it cannot be done :) If wrap=soft isn't working in Firefox, then your fancy-dancy CSS is messing things up somehow, or you've managed to do something else really weird... Firefox wraps just fine for me, in all the textarea inputs I've ever used. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Sun, Mar 30, 2008 at 12:26 AM, Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Sounds like you're using literal quotes here, Mary. Single quotes ('like this')take all data between them as literal, while double quotes (like this) translate things within. $a = Hello!; $b = I just wanted to say: $a; $c = 'I just wanted to say: $a'; $d = The quick brown fox jumped over the lazy dogs.\n; $e = 'The quick brown fox jumped over the lazy dogs.\n'; The above will output as follows: $a: Hello! $b: I just wanted to say: Hello! $c: I just wanted to say: $a $d: The quick brown fox jumped over the lazy dogs. (with a newline) $e: The quick brown fox jumped over the lazy dogs.\n You may instead want to use HEREDOC syntax. $text =EOT This will allow for actual newlines to be carried over. This also means that Windows-vs-Linux-vs-Mac newlines are translated exactly as they were entered, so if you're typing the data into the HEREDOC in a standard Windows environment, you'll have \r\n, whereas Linux will have \n, and Mac will have \r. Keep in mind, in a HEREDOC, those newline characters will not translate, but variables will. $b EOT; As always, if you want a newline after the final text is typed, include one full blank line after. And always end your HEREDOC by typing the signifier as the first character on the line. Sorry if this is dumbing it down for you, but I wanted to take the opportunity to not only address what may be your problem, but also put this tidbit into the archives with the question you asked, since someone down the road may very well find your question with that problem. ;-) -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
Is \n included literally because you're using single quotes for the variable? $textdata = 'This is a test\nThis is the second line'; vs... $textarea = This is a test\nThis is the second line; I would guess a lot of the pages you find are talking about what to do with the text after submitting through the textarea, not re-displaying with proper breaks when loading a page containing a text area that should have data. -TG - Original Message - From: Mary Anderson [EMAIL PROTECTED] To: php-general@lists.php.net Date: Sat, 29 Mar 2008 21:26:24 -0700 Subject: [PHP] new lines in textareas? Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Apologies if this should go to an HTML forum. I checked several archives and did not find anything useful. (They tended to tell me to put in \n or br!) Thanks Mary Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Sun, Mar 30, 2008 at 2:07 PM, TG [EMAIL PROTECTED] wrote: Is \n included literally because you're using single quotes for the variable? $textdata = 'This is a test\nThis is the second line'; vs... $textarea = This is a test\nThis is the second line; I would guess a lot of the pages you find are talking about what to do with the text after submitting through the textarea, not re-displaying with proper breaks when loading a page containing a text area that should have data. -TG - Original Message - From: Mary Anderson [EMAIL PROTECTED] To: php-general@lists.php.net Date: Sat, 29 Mar 2008 21:26:24 -0700 Subject: [PHP] new lines in textareas? Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Apologies if this should go to an HTML forum. I checked several archives and did not find anything useful. (They tended to tell me to put in \n or br!) Thanks Mary Anderson my client ask me about this problem 2 weeks ago. he want the text to automatically go to new line after user type until the end of the line. The only possible solutions so far is using wrap='hard' or wrap='soft' eg: textarea cols=10 rows=10 wrap=hard but wrap only work on IE Netscape browser. Not working in firefox. i guess i want to use javascript to do the text formatting. trigger the javascript event every time the user using the onchange event (i never try).. i is quite complicated i dont have much time working on it. so i decided to tell him, it cannot be done :)
Re: [PHP] new lines in textareas?
At 9:26 PM -0700 3/29/08, Mary Anderson wrote: Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Apologies if this should go to an HTML forum. I checked several archives and did not find anything useful. (They tended to tell me to put in \n or br!) Thanks Mary Anderson Show the code. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Sun, 2008-03-30 at 12:29 -0400, tedd wrote: At 9:26 PM -0700 3/29/08, Mary Anderson wrote: Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Only getting to this now, but doesn't nl2br() do what you want? --Paul -- . | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :: All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Mon, Mar 31, 2008 at 12:40 AM, Paul Scott [EMAIL PROTECTED] wrote: On Sun, 2008-03-30 at 12:29 -0400, tedd wrote: At 9:26 PM -0700 3/29/08, Mary Anderson wrote: Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Only getting to this now, but doesn't nl2br() do what you want?http://www.php.net/unsub.php well, i don't think nl2br() is a solution here because nl2br() only replace the '\n' with br/ html tags which is displayed inside the textarea. the textarea will display a new line with '\n'.. $str = hello\nworld; will display hello world in text area. but $st = 'hello\nworld'. will be display as hello\nworld just like what TG trying to say..
[PHP] new lines in textareas?
Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Apologies if this should go to an HTML forum. I checked several archives and did not find anything useful. (They tended to tell me to put in \n or br!) Thanks Mary Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Sat, Mar 29, 2008 at 9:26 PM, Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Apologies if this should go to an HTML forum. I checked several archives and did not find anything useful. (They tended to tell me to put in \n or br!) Thanks Mary Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php \n, or just a plain line break, should work. ?php echo 'textareaHello, My favorite color is blue. Signed, Me!'; ? Should work. -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php