Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Shown multiline output text from the textbox (PHP4)

Posted on 2004-03-23
9
Medium Priority
?
522 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Six Sigma Control Plans
Progress

916 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