Solved

Shown multiline output text from the textbox (PHP4)

Posted on 2004-03-23
9
493 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

11 Experts available now in Live!

Get 1:1 Help Now