Solved

Formatting output from a longtext field

Posted on 2007-03-17
5
229 Views
Last Modified: 2012-05-05
Experts,

I have a column within my database message table, which is a longtext field.  This is used to store messages that the user has sent to me.

I need to know how to format the output so that it includes the new rows, when the user has pressed the "enter" key.

0
Comment
Question by:mhouldridge
[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
  • 2
  • 2
5 Comments
 

Author Comment

by:mhouldridge
ID: 18740327
I have now;

<? echo "<font class=\"text11\"><pre>".$formVars['message']."</pre></font>"; ?>

This includes the formatting, however the length of the question pushes the table out to the full screen.  I have specified the length of 500px, however it still pushes it out.
0
 

Author Comment

by:mhouldridge
ID: 18740383
Ah, ive got it;

<? echo nl2br("<font class=\"text11\">".$formVars['message']."</font>"); ?>
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18740729
Did you answer this yourself then or did you still have a question?  Let me know if I can help still but it seems like you found the "magic" function. :)

By the way, the font tag is deprecated (losing support).  I suggest using <p>, <div> or another tag.

bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18740739
Actually, the best place to use the nl2br function would be ...

<? echo '<font class="text11">' . nl2br($formVars['message']) . '</font>'; ?>

Let me know if you have a question.

bol
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 250 total points
ID: 18742783
You probablywant to add some htmlspecialchars as well:

<font class="text11">
<?php
  echo nl2br(htmlspecialchars($formVars['message']));
?>
</font>

You also might to think about changing your <font>-tag into a <span> tag, as font tag's are deprecated.

Kind regards

-r-
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
clicking to find my folders on wamp 8 47
Compiling PHP with Curl plus protocols 8 48
How to hide contact form only if no validation errors 4 65
Format Date 7 28
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

752 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