RE: [PHP-DB] Line breaks from a database!
Well, here's what I got, since I put the data into the table directly it had no extra slashes so it looked like this '\n' , but when retrieving it i ended up with '\\n'. I would have expected stripSlashes to work but that turned them into 'n'. Here's what I did as a workaround: function strip($string){ $string = str_replace(\\n,\n, $string); return $string; } believe it or not, this works when stripSlashes does not. Anyone know why? Ryan Ryan Jameson (USA) [EMAIL PROTECTED] said: Hi guys, maybe I'm missing something silly but when I retrieve a string from my SQL server with '\n' in it, they are displayed literally instead of as line breaks. StripSlashes only turns them into 'n'. Any ideas? Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] line breaks in mySQL text fields
On Monday 23 July 2001 11:16 am, kmurrah wrote: How do I add new line characters to a text field in mySQL ? i.e. i need to manually insert returns into my text ... thanks in advance, KennM Does the \n not work? I dont have time to try it write now but did you try it? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] line breaks in mySQL text fields
Hi, You could put \n where you want the new line. Than if you want to output the text field in HTML you could use nl2br() to replace the new line characters with br For example take a look at this INSERT query: $sql= INSERT INTO table_name (text_field,...other_fields) VALUES ('first row\nsecond row',...other_values); Hope this helps Dobromir Velev -Original Message- From: kmurrah [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Monday, July 23, 2001 9:15 PM Subject: [PHP-DB] line breaks in mySQL text fields How do I add new line characters to a text field in mySQL ? i.e. i need to manually insert returns into my text ... thanks in advance, KennM -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Line Breaks
nl2br() -Original Message- From: Shope, Glenn [mailto:[EMAIL PROTECTED]] Sent: 23 March 2001 20:49 To: '[EMAIL PROTECTED]' Subject: [PHP-DB] Line Breaks Still haven't figured it out... I have read several entries about preserving line breaks when displaying text from a mySQL database, but I have had no success. How would I prevent data in a single field containing line breaks from being displayed in HTML as a single line? For example: A person fills out a form with this information: "My name is Chris. I like to swim." Ho do I prevent PHP from writing it as "My name is ChrisI like to swim." ??? I have tried a EREG_REPLACE and PREG_REPLACE attempting to replace "\n" with BR, but it doesn't seem to do the trick. Any help would be greatly appreciated!! Glenn :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Line Breaks
Thanks, I have finally figured out the syntax for nl2br(), which doesn't seem very clear in the manual. I used: $data = nl2br($data); That returns just what I expect. However, now I have to get rid of the all the BRs that I have inserted into my data while I was trying to figure this out. Thanks for the responses. -Original Message- From: Matt Williams [mailto:[EMAIL PROTECTED]] Sent: Friday, March 23, 2001 3:30 PM To: Shope, Glenn; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Line Breaks nl2br() -Original Message- From: Shope, Glenn [mailto:[EMAIL PROTECTED]] Sent: 23 March 2001 20:49 To: '[EMAIL PROTECTED]' Subject: [PHP-DB] Line Breaks Still haven't figured it out... I have read several entries about preserving line breaks when displaying text from a mySQL database, but I have had no success. How would I prevent data in a single field containing line breaks from being displayed in HTML as a single line? For example: A person fills out a form with this information: "My name is Chris. I like to swim." Ho do I prevent PHP from writing it as "My name is ChrisI like to swim." ??? I have tried a EREG_REPLACE and PREG_REPLACE attempting to replace "\n" with BR, but it doesn't seem to do the trick. Any help would be greatly appreciated!! Glenn :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Line breaks in output
Better yet, use "br" for browsers. Or use Jeff's method but use nl2br function to convert new line to br echo nl2br($result); ""JJeffman"" [EMAIL PROTECTED] wrote in message 007f01c0b0d8$212e97a0$5bd4d7c8@jjeffman">news:007f01c0b0d8$212e97a0$5bd4d7c8@jjeffman... Create a variable to concatenate the item values adding a "\n" character between them : $result = $item1."\n".$item2."\n".$item3 ; . echo("input name=text value=".$result . ""); HTH Jayme. -Mensagem Original- De: Martin Skjöldebrand [EMAIL PROTECTED] Para: [EMAIL PROTECTED] Enviada em: segunda-feira, 19 de março de 2001 17:47 Assunto: [PHP-DB] Line breaks in output Newbie here. How do I get line breaks in output from a database? I have a list of things in a file, like: item1``item2``item3 (etc) I want them displyed in a textarea as: item1 item2 item3 Probably very simple, haven't got that far in my book yet. Martin S. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]