Solved

Shown multiline output text from the textbox (PHP4)

Posted on 2004-03-23
9
500 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
This is an explanation of a simple data model to help parse a JSON feed
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 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…

803 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