PDA

Click to See Complete Forum and Search --> : [RESOLVED] Problem: showing text in new line


shamsoft
Jun 13th, 2007, 06:22 AM
Hi my dear
I have a problem in php/mysql
For example I write below text to textarea and save it to mysql:
Hi
I am ShaMSofT
and i like programming

bye bye
now i want to retrieving my data from mysql and use echo function to show it. like:
//save mysql data in $text
echo $text;
but this statement show below data:
Hi I am ShaMSofT and i like programming bye bye
i see my data in table of mysql and data saved all right like first code. now i do not know why php show it like third code
help me,please

thanks to all reader this topic :thumb:

--------------------
sorry for bad my english :o

McCain
Jun 13th, 2007, 07:15 AM
If you look at the source code for the webpage you echo the text to you'll see the linebreaks. But the way html works is to ignore linebreaks in the source, that's why you see it as if it were all on one line. So solve it you need to use the nl2br() function in your php file

penagate
Jun 13th, 2007, 07:18 AM
PHP's default content type is text/html, but if you're not marking up HTML then just send it as plain text.

// Add this before beginning output.
header('Content-type: text/plain');

shamsoft
Jun 13th, 2007, 09:21 AM
Thanks To McCain & penagate :thumb:

penagate
Jun 13th, 2007, 09:25 AM
No problem.

Also, thanks for trying but the proper way to mark the thread resolved is using the Thread Tools menu above the first post. I did it for you this time. :)