Solved

Shown multiline output text from the textbox (PHP4)

Posted on 2004-03-23
9
496 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parentbit challenge 3 72
allswap challenge 6 75
listing all functions in JavaScript 19 173
move one pixel 4 58
A short article about problems I had with the new location API and permissions in Marshmallow
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

929 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now