|
-
Jun 13th, 2007, 06:22 AM
#1
Thread Starter
Member
[RESOLVED] Problem: showing text in new line
Hi my dear
I have a problem in php/mysql
For example I write below text to textarea and save it to mysql:
Code:
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:
Code:
//save mysql data in $text
echo $text;
but this statement show below data:
Code:
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
--------------------
sorry for bad my english
Sorry For Bad My English 
-
Jun 13th, 2007, 07:15 AM
#2
Fanatic Member
Re: Problem: showing text in new line
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
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
-
Jun 13th, 2007, 07:18 AM
#3
Re: Problem: showing text in new line
PHP's default content type is text/html, but if you're not marking up HTML then just send it as plain text.
PHP Code:
// Add this before beginning output.
header('Content-type: text/plain');
-
Jun 13th, 2007, 09:21 AM
#4
Thread Starter
Member
[Resolved]
Thanks To McCain & penagate
Sorry For Bad My English 
-
Jun 13th, 2007, 09:25 AM
#5
Re: [RESOLVED] Problem: showing text in new line
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|