Solved

Shown multiline output text from the textbox (PHP4)

Posted on 2004-03-23
9
511 Views
Last Modified: 2012-08-14
how to shown multiline output text from the textbox value.
I have use this but it seem not working
htmlspecialchars(str_replace("vbcrlf", "<br>", $message), ENT_QUOTES);
0
Comment
Question by:ztot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 1

Expert Comment

by:anupbhunia
ID: 10655964

Dear Sir,
what you does is perfect.
htmlspecialchars(str_replace("vbcrlf", "<br>", $message), ENT_QUOTES);

it actually should be like
htmlspecialchars(str_replace(vbcrlf, "<br>", $message), ENT_QUOTES);

vbCrlf is a constant so you should not use quotation. try it.
0
 

Author Comment

by:ztot
ID: 10656021
htmlspecialchars(str_replace(vbcrlf, "<br>", $message), ENT_QUOTES);

ERROR
--------
Notice: Use of undefined constant vbcrlf - assumed 'vbcrlf' in c:\program files\apache group\apache\htdocs\sendmail.php on line 60
0
 
LVL 2

Expert Comment

by:DonRameshSachin
ID: 10656125
wht u can do is put the constant value of vbcrlf or otherwise u can try char(13) or char(10) instead of vbcrlf

Don
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:ztot
ID: 10656293
it can send the mail successfully, but the content still not in multiline. Pls advise, thanks.

>wht u can do is put the constant value of vbcrlf or otherwise u can try char(13) or char(10) >instead of vbcrlf
0
 

Author Comment

by:ztot
ID: 10656340
htmlspecialchars(str_replace(chr(13), '<br>', $_POST["txtDescription"])

Output
--------
Line1<br> Line2<br> Line3
0
 

Author Comment

by:ztot
ID: 10656403
Here is my code:
 
<tr>
    <td colspan="2">'.htmlspecialchars(str_replace(chr(13), "<br>", $_POST["txtDescription"])).'</td>
  </tr>
0
 
LVL 2

Expert Comment

by:DonRameshSachin
ID: 10656448
can u try like this
<tr>
    <td colspan="2">'.htmlspecialchars(str_replace(chr(13) & chr(10), "<br>", $_POST["txtDescription"])).'</td>
  </tr>

Don
0
 

Author Comment

by:ztot
ID: 10656460
can u try like this
<tr>
    <td colspan="2">'.htmlspecialchars(str_replace(chr(13) & chr(10), "<br>", $_POST["txtDescription"])).'</td>
  </tr>

Don

Output
-------
Line1 Line2 Line3

: (
0
 
LVL 3

Accepted Solution

by:
odders earned 50 total points
ID: 10673068
\n is how the new line is specified, and \r is how a return is specified, in php anyway. try using the function nl2br(), or you can use str_replace(). heres some examples:

nl2br(htmlspecialchars($message, ENT_QUOTES);

htmlspecialchars(str_replace("\n", "<br>", $message), ENT_QUOTES);

if they dont work (first one is prolly the best to use), try the second one, but with \r instead. nl2br actaully reatins the newline, as well as adding a <br /> tag, so your output is nicley foramttted as well.

alternativley, you could just stick it in a pre tag:

echo("<pre>".$message."</pre>"). that also retains character spacing, but isnt the prettiest looking.

good luck...
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question