Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Converting Html Code To Real Line Breaks In A Textarea


I am having some trouble with converting html code to real line breaks in a textarea, I have the following code that I gets html code from a database and then puts it into a textarea but the str_replace I am using converts the text but puts the actual characters in the textarea, and doesn't actually turn it into a linebreak. (the br below is reality in triangular brackets!)

$paragraph=$row['paragraph'];
$paragraph=str_replace('br','
',$paragraph);
.....
<textarea name="ud_text" cols="50" rows="15" maxlength="300"><? echo $paragraph ?></textarea>

Perhaps someone can help me with this?




View Complete Forum Thread with Replies

Related Forum Messages:
Any Way Of Removing Line Breaks From HTML Code?
I have a big big chunk of HTML code stored inside a variable $myhtml. Is there any way I can possibly remove all line breaks in the HTML?

I tried $myhtml = str_replace('
', '', $myhtml);
but it doesn't work.

View Replies !
Textarea Line Breaks Without Using <p>?
When submitting from a <textarea> within a form, line breaks are irrelevant - you can put every word on a separate line, and they'll all end up together. At the moment I'm asking people using my article submission system to insert a <p> at the start of each new paragraph - but aside from being a pain, non HTML-literate users don't understand why they have to do it...

So.. what's the best way to convert line breaks into <br> tags using PHP? Like this forum does, for example?

View Replies !
Line Breaks In A Textarea
Didn't know exactly where to post this, but: How do I get line breaks in a textarea? I'm pulling text from a database, and this text definately has line breaks in it, because I replaced all the line breaks with <br /> tags ( using the php function
nl2br() ), and <br /> tags showed up in the textarea.

View Replies !
Validating Line Breaks In A Textarea
Well I stared writing all my eregi() validation today. Everything works fine except for the textarea validate for a business description. I allow the business to have multiple l lines in their description. I can't seem to get it to work.

Basically I am just validating it to make sure no one can type in javascript or other code and have the server run it. Am I being to paranoid ? If not, how in the heck do you validate line breaks?

View Replies !
Line Breaks In Textarea ( Submitted To Db )
i have a form which has a text area for teh user to enter multiple lines of data

now , this gets added to the database and then retrived on a further page

if they type
something
like
this

how do i get it saved in teh db as that and not as :

if the type something like this Code:

View Replies !
Textarea :: Line Breaks And Wrap
I have a textarea in a form which has been created like this:

<textarea name="textarea" wrap=hard cols=100 rows=25></textarea>

The wrap element is declared as 'hard' meaning the text wraps in the textarea and the linebreaks are stored in the database. The field storing the content of the textarea is declasred as a 'longtext' but when the data is retrieved from the database the linebreaks arentaccounted for and a continuous string is returned.

View Replies !
Using Nl2br To Add Line Breaks In Textarea Field
I'm trying to maintain line breaks when a user adds information to a textarea field. Now, this is fairly straight forward, but I've run into a few problems I'm sure someone here could fix up pretty quickly.

Below is how I;m currently using nl2br:

$row->custom1 = ampReplace( nl2br($row->custom1) );
$row->custom2 = ampReplace( nl2br($row->custom2) );
$row->custom3 = ampReplace( nl2br($row->custom3) );

Now this works ok, as it adds the required line breaks to the field. The problem occurs when a user makes additional changes to the form and resubmits it. Now it adds an additional line break to the form, so it now appears with two carriage returns. If he/she re-edits it, there would be three tags.

So my question is twofold:

1. How can I use nl2br (or some other method) to maintain line break within a text area field without displaying the tag when the form is re-edited?

2. How can I avoid multiple line breaks when the form is edited and re-submitted?

I apologize if this has been touched on before. I begin all posts by first searching previous posts, but I either did not find what I was looking for, or failed to understand what was being explained.

View Replies !
Converting Line Breaks To <br /> And <p> </p>
I'm working on a blogging platform, and I'm struggling with the final output (what the end users/web visitor sees).

I've got to the stage where the data stored in the database in 100% correct.

My problem is converting line breaks to <br /> and <p></p>.

An example database stored entry:

<h2>A Testing title!</h2>

A list:

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

Another paragraph.

This is how I'd like it to be displayed to viewers:

<h2>A Testing title!</h2>
<p>A list:</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<p>Another paragraph.</p>

I've tried: nl2br and replacing double '<br />' to '</p><p>', but this messes up the HTML lists and sometimes H tags.

What I really want is a nl2br function that doesn't work between block level elements.

View Replies !
Send Non-html Mails That Still Uses Line Breaks
I'm fixing a mailing list for our site. Is there a way to send non-html mails that still uses line breaks and such through php? Or even better a way to send an email to an adress that redirects it all to a maillist that stored in an mysql table.

View Replies !
How To Output Code From A Html Textarea
Iv made a mysql table and PHP files wich can Add, Edit, View and Delete text and data from the mysql table.

The problem is that when I try to view php scripts from the mysql table from web the php code is shown as html text, and the PHP tags are removed.

For example I would like to view PHP code with the show_source on my webpages.
How do I do that? Code:

View Replies !
Entering Html And Php Into A Db And Display This In A Textarea Without It Being Processed As Code
how can i enter html and php into a db and display this within a
TEXTAREA without it being processed as code? do i need to replace
characters like <? with something else like say <..? or is there a more
elegant solution that tells the php parser etc to ignore this section
as it needs to be processed as text not code.

View Replies !
Exploding At Real Breaks Not Wraps
I am working on reading my  pop3 email , and I am trying to return the header data using the function, I get this fine. The question I have is since there is no consistency to the rows, I want to take each row of data, not a wrap of a long line, any idea beyond checking if it has a : in it???

View Replies !
Converting A Html Code To Pdf In Multi Column With FPDF
I want to output some text to pdf file using FPDF. Outputting a text is good even with multi columns.But what I need is I need that text to be formatted. Like Some text to be bold and italic etc.

I can either make a multi column pdf or a html formatted page to PDF, but I want both of them.I couldnt integrate both the functions and from the forums I found someone refering HTML2PDF, but I also need multi column with it..

View Replies !
Parse Error On The Last Line Of Code </html>
/// here is the code i'm getting a parse error on the last line of the
code which
/// is </html> any help will be much appreciated.

<?php

session_start ();
require_once('connect.php');

if ($_SESSION['username']){ //test for logged-in
$query = "SELECT status FROM accounts WHERE
username='".$_SESSION['username']."'";
$result = mysql_query ($query) or die("<b>A fatal MySQL error
occured</b>.
<br>
Error: (" . mysql_errno() . ") " . mysql_error());
$row = mysql_fetch_array ($result,MYSQL_NUM);

if ($row[0] == 0){
$error_message .= "<P>Your account has been frozen. Email the <A
HREF='mailto:account_status@severedrealm.net'>webmaster</A> for more
information.</P>";}

if ($row[0] == 1){
$query2 = "SELECT name, hp, gold, exp FROM characters WHERE
username='".$_SESSION['username']."'";
$result2 = mysql_query ($query2) or die("<b>A fatal MySQL
error occured</b>.
<br>
Error: (" . mysql_errno() . ") " .
mysql_error());
$character_table .= "<TABLE CELLSPACING=&#392;' CELLPADDING=&#392;'
BORDER=&#390;'><TR><TD>Name</TD><TD>Hit
Points</TD><TD>Gold</TD><TD>Experience</TD><TD>Delete</TD></TR>";
$x=0;
while ($character = mysql_fetch_array ($result2)) {
$x=$x+1;
$character_table .=
"<TR><TD>".$character[1]."</TD><TD>".$character[2]."</TD><TD>".$character[3]."</TD><TD>".$character[4]."</TD>";
$character_table .= "<TD><form action='character.php'
method='post'><input type='hidden' name='character'
value='".$character[1]."'><INPUT TYPE='submit'
NAME='delete_character_submit'
VALUE='delete_character'></FORM></TD></TR>";}
$character_table .= "</TABLE>";
if ($x >= 1){
$error_message .= "<P>You have too many characters. You must
delete ".$x."before you can create another.</P>";
}else{
$character_creation_form .= "<FORM
ACTION='character.php?op=create_character' METHOD='post'>";
$character_creation_form .= "<table cellspacing=&#392;'
cellpadding=&#392;' border=&#390;'><tr>";
$character_creation_form .= "<td>New Character
Name:</td><td><input type='text' name='new_character_name' size=&#3930;'
maxlength=&#3930;' value=''/></td></tr>";
$character_creation_form .= "<tr><td></td><td><input
type='submit' name='New_Character_Submit' value='Create
Character'></td></tr></table></FORM>";}

if ($row[0] == 2){
$query3 = "SELECT name, hp, gold, exp FROM characters WHERE
username='".$_SESSION['username']."'";
$result3 = mysql_query ($query3) or die("<b>A fatal MySQL
error occured</b>.
<br>
Error: (" . mysql_errno() . ") " .
mysql_error());
$character_table .= "<TABLE CELLSPACING=&#392;' CELLPADDING=&#392;'
BORDER=&#390;'><TR><TD>Name</TD><TD>Hit
Points</TD><TD>Gold</TD><TD>Experience</TD><TD>Delete</TD></TR>";
$x=0;
while ($character = mysql_fetch_array ($result2)) {
$x=$x+1;
$character_table .=
"<TR><TD>".$character[1]."</TD><TD>".$character[2]."</TD><TD>".$character[3]."</TD><TD>".$character[4]."</TD>";
$character_table .= "<TD><form action='character.php'
method='post'><input type='hidden' name='character'
value='".$character[1]."'><INPUT TYPE='submit'
NAME='delete_character_submit'
VALUE='delete_character'></FORM></TD></TR>";}
$character_table .= "</TABLE>";
if ($x >= 2){
$error_message .= "<P>You have too many characters. You must
delete ".$x."before you can create another.</P>";
}else {

View Replies !
Send A HTML Line Of Code To A Flash File
I'm trying to send a HTML line of code to a flash file, but php is running it as html, instead of seeing it as plain text.

file.swf?name=<?php echo $code; ?>

I need to somehow echo the $code as plain text instead of php running the html.

View Replies !
Line Breaks In PDF
I am trying to create PDF-s using PDFLIB. This works fine, as long as the printed text does not exceed one line. I cannot create a linebreak, so when I use the code below, the text seems to run of the screen.

View Replies !
Line Breaks
I've got in mysql table a TEXT field where I've got this contents:
"This
is a
text"

Now, I want to put this text into a javascript but than I need it convert it this way : "This
is a
text"

Do you think this is possible?

View Replies !
(H) In Line Breaks
I have a cell phone with full internet access. I have an HTML page
that I wrote specifically for use on my cell phone. It uses PHP's
fopen() to open files on my server and then displays the contents of
the file I opened using a <textarea>. This allows me to update my site
from my cell phone.

It works fine from a browser on my computer, but when I use it to open
a file from my cell phone, all the line breaks are preceded by this
character that looks like a copywrite symbol, but with an (H).
Extended ASCII 233 according to http://www.asciitable.com . I write
the pages in Dreamweaver MX initially, which gives me a few options
about how to write line breaks (either for Linux, Windows, or Mac; CR,
LF, CR LF) but I need my files to work on all three of my operating
systems, since I use a Mac a home, a PC at school, and my server is
Linux.

I'm guessing that my computer is writing CR LF and my cell phone is
interpreting it using a different character set where 233 means this
(H) thing instead of CR. But how can I get rid of these characters?
Possibly, could I use PHP to check the user-agent of the client to find
out whether it's a cell phone, then replace all CRLFs with just LFs?
And would I need to put them back in afterwards? If so, how?

View Replies !
Line Breaks Using PHP
I have a PHP script that I need debugging. Below is part of a script I have going. It bascially outputs what has been entered in the form field. Currently, it outputs a long line with no breaks. How can I add paragraph breaks after 25 words or so?

View Replies !
Line Breaks?
A user inputs a news article into the database and then I echo it out onto the front end. However line breaks aren't kept and the text string is stripped of spacing.

So the user inputs into the textbox QuoteLorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec tincidunt. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec risus. Nullam faucibus. Code:

View Replies !
Line Breaks...
On my news system I made when I type into the text area and add line breaks and what then submit the form when I go to view the news story the line breaks are gone, are a result it looks like I dont understand the meaning of paragraphing.

View Replies !
Line Breaks Only
Here is what I want to do where users post forum post on my site. It will add a new line automatically if you press enter. If you use html code then it will not add a new line automatically. I know how to add new line breaks but not how to do it when a user has html code

View Replies !
Question Re Line Breaks
for line breaks in the message body for correct display
in Windows email clients.

If the send fails [mail() = false], I save the message to an XML file, and
attempt a re-send later.

Is it OK to save the body with line breaks, or will this mess up
reading the file later with fgets()? How does fgets() deal with line breaks?

View Replies !
Line Breaks Using Php Str_replace
im building a pm system and i cant quite figure out how to make it recognize line breaks.
a good ex is using vbulletin. when u fill out teh message it remembers all your line breaks and outputs them as such. but when i made the pm system it bunches all the different lines into 1 long line.

View Replies !
PHP Line Breaks Not Showing
I am starting to learn php and I am alraedy struggeling with the basics. My PHP program is not showing any Line Breaks :-( I wrote a program "test.php". Instead of doing line breaks, he is doing everything in one line. I tried it on my local Windows machine with Apache installed as well as on my Webhoster's server.

<?php
echo " line 1
line 2
line 3";
echo nl2br ("line A");
echo nl2br ("line B");
echo nl2br ("line B");
?>

I start to feel stupid. Anybody an idea?

View Replies !
Inserting <br /> At Line Breaks?
Does anybody know how it is done so that if somebody presses enter in a textarea teh code will detect it and insert a

View Replies !
How Do I Make Line Breaks Without <br />??
I have a input form where i type in alot of text, this text is then stored in the database. When i pull the data out of the database to show on the screen there are no line breaks. The text is just printed out in one long text.

How do i make automaticly line breaks without using
, when i type in the form input? Code:

View Replies !
Line Breaks In Forms
i have noticed that when a user is typing in a form, when they do a line break

line 1
line 2
line 3

it displays as line 1rn line 2rn line 3rn, i did this:

$comments = mysql_real_escape_string($_POST["comments"]); 
$comments = stripslashes($comments);

not sure if i have done that right it stll displays the same and advice would be great.

View Replies !
Line Breaks In Variables?
I'm using this line to send an email...

mail($email2, "XXXX.com: Registration- Thank you.", $body, $headers);

Now the variable $body is quite long and needs to be formated..

so i tried this:

$body = "Welcome
This is a test
1)blahblah
2)blahblah";

Where the outcome i would expect is:

Welcom
This is a test
1)blahblah
2)blahblah..


obviously isn't formatting with '
'...  any other ways to format in variables or am i chasing a ghost?

View Replies !
Preserve Line Breaks
Is there a php string function that will preserve the line breaks that a user enters into a <textarea> on a form?  I've been manually using <p> or <BR> in the textarea, and now that I'm opening up the form to other users, I can't rely on them using it. These forums are able to do it. how is it done?

View Replies !
Preserving Line Breaks
i have a textfield called "note" in a form which uses POST to give it's input to another file. now here's my question: how can i preserve line breaks from the input? the next document uses

$note = $_POST["note"];

but it puts everything into a single line! is there a simple way to tell my script that it should keep the format the user intended?

View Replies !
Preserving Line Breaks Etc
I'd like to save a simple bit of web content in a table using a LONGTEXT field.

Of course, I'd like to put line breaks and HTML tags within the content.

I've seen this spoken about but can't find what I'm after just now.

View Replies !
Add Line Breaks Function
I have a page with a single textbox and submit button. When the page is processed on itself, it emails somebody the response. When I get the email response, the message submited doesn't include line breaks. How do I add line breaks? You can see in the code below that when $message (its inside $message1) is displayed, it doesn't add the appropriate line breaks if there should be line breaks there. How can I fix that?

<?php
$submit = $_POST['submit'];
$message = $_POST['message'];
if( isset($submit) ) {

$message1 = "<table width="500" cellspacing="0" cellpadding="0" border="0" align="center" style="border:1px solid #CCCCCC;"><tbody><tr>
  <td><img src="http://www.theprrt.com/images/email/default-superspine-header.gif" /></td>
</tr><tr><td style="padding: 20px 30px; font-size: 10pt; font-family: Arial,Helvetica,sans-serif; line-height: 1.3em; text-align: justify">
    <p> $message </p></td></tr><tr><td><br>
<img alt="" src="http://www.theprrt.com/images/email/email-........

View Replies !
<br/>'s For Line Breaks In A Form
Simply I have a form and when users submit a post on my guest book I need when they press enter (line break) in the form that I have to do some kind of preg_replace and replace that linebreak with a break tag.

View Replies !
Automatic Line Breaks <BR> ...
I have a form which includes a <textarea> ... at the moment when staff at the station are inserting data.. they need to put <br> between lines etc.. I don't want to go down the route of having to use a WYSIWYG editor, they are quite expensive!!! Code:

View Replies !
Line Breaks In Mail
i'm using the php mail() function and I cant seem to get line breaks insde of the mails that are sent. here is the code i'm using: Code:

View Replies !
Why The Extra Line Breaks
I'm trying to get something that reads out of a database and then has a drop down menu for each piece it gets out of the data base i.e.

car1 color option box
car2 color option box
car3 color option box
car4 color option box
car5 color option box

where color option box is a drop down menu with different choices, with the eventual goal of updating the database with changes made.

Right now I can't figure out why the drop boxes appear one line below the leader for the line, I also can't figure out why the extra drop box is being generated at the end. Code:

View Replies !
All Text Email - How Do You Add Line-breaks?
Sending an all text email through php.

How do I put line breaks in the message, I was unable to google it

I know you can use "", but like, what else can I do, what is this stuff even called, language, so I can find out what the stuff does?

View Replies !
Line Breaks In MySQL Fields
I've made my first project as a searchable database of song tracks and lyrics. I'm storing all the data, including full lyrics for each track in a MySQL table.

The problem is that I can't put each line of the lyrics onto a new line in the database field. I'm using phpMyAdmin, and when I put each line of the lyrics on a new line they are simply run together as one long single line when stored. I need it to be saved in the database with new lines, so it can just be easily printed out onto a page already broken up into verses.

The only other alternative I can think up is using <br> tags within the data, but I don't want users to be presented with all the results when they search for <br>.

View Replies !
Line Breaks When Reading A File
Consider the code:

$arrText = file ("http://www.site.com/page.htm");
for ($i=0; $i<count($arrText); i++) {
echo("$arrText[$i]
");
}

(I did not test the snippet for errors)

The line breaks appear to be different from the original .htm file. Why?

View Replies !
Removal Of Line Breaks In Strings
I was looking through the php manual and the closest thing I can find that will do this is the nl2br() command, but this will only get me so far. My dilema is this:

I have a <textarea> (among other things) in a form that is submitted to a PHP formhandler. The formhandler then takes all the variables gathered from the form and compiles them in a string, and then spits it out to a text file. I want the text file to be all one line, but <br> tags are allowed (enter the nl2br() command) but that still leaves the linebreaks in the string. I was looking at the strtr() command but I dont know if a linebreak has a specific character I can change to a <BR> tag, thus eliminating the nl2br command.

View Replies !
Line Breaks In Php Email Forms
my email form works great, but when I get the data in the email it's not double spaced and I want there to be room between each thing of data. This is what it looks like now:

Name:
Email:

And I want it to look like this:

Name:

Email:

When I open up my email so that my data doesn't look so clustered. How do I do this?

View Replies !
How To Remove Multiple Line Breaks?
I'm am trying to remove multiple line breaks ("
"). Here's my code:

$imageStr = trim($_POST['images']);
$imageStr = str_replace("

", "
", $imageStr);

----------

$_POST['images'] is a textarea field, and I am trying to remove extra
hard returns that a user types into the text area.

When I change the code to:
$imageStr = str_replace("
", "%", $imageStr);
it works fine. So I know the function works and I have the right
character ("
").

View Replies !
Regex With Possible Multiple Line Breaks
I want to crawl through userprofiles on a site, but users have the possibility to use line breaks in their profile. The profiles look like this: Code:

View Replies !
Putting In Line Breaks In A While Loop?
im trying to run a while loop that puts in breaks (
) when 3 pictures have been displayed.

<?php
while($catListRow = mysql_fetch_array($searchQuery)){
echo "<p><a href='gallery.php?action=3&no=".$catListRow['download_id']."&cat=".$catListRow['download_cat']."'><img src='".$catListRow['download_url']."' height='100' alt='".$catListRow['download_title']."' /></a></p>";
}
?>

as the code are at the moment it just prints out all the pictures in one long line. How do i get the script to put in a line break everytime 3 pictures have been printed?

View Replies !
Line Breaks Doesn't Show Up
I have a script that allows users to post ads and stuff, but the thing is when they go to the description and fill that out if they want to enter a space like this. it doesn't show up, it acts like it was on the same line. How can I fix this?

View Replies !
Remove Extra Line Breaks
What is the correct expression to remove any extra line breaks beyond two in a string?

View Replies !
How Line Breaks Are Added To Database?
how line breaks are added to database? When a user edits a description and updates database i want line breaks for each time the database is updated. Then i want to be able to show line breaks when a user retrieves the data,

e.g user added stuff on 24/10/05
user added more stuff on 24/10/05
user added even more stuff 25/10/05

rather than:

user added stuff on 24/10/05user added more stuff on 24/10/05user added even more stuff 25/10/05

View Replies !
Line Breaks? - Echo Out The Description
I'm submitting a form and trying to echo out the description. The description is typed into a text area field. When I echo the value, it does not include the line breaks. Code:

View Replies !
Place 3 Line Breaks After The $message
I'm having a strange problem with the code below, I am trying to get it to place 3 line breaks after the $message (so i can then display: sent by: $name -$from) but it wont even break a single line?

$body="$message
sent by: $name - $from";
$from=""$name" <$from>";
$headers="Content-Type: text/html; charset=Windows-1252";
$headers.="From: $from";
mail($to,$subject,$body,$headers);



View Replies !
Does Not Having Line Breaks In Your Output Effect Anything?
Function? Spiderability? Any reason to worry about not having line breaks in automatically-generated html?

View Replies !
Function To Convert Line Breaks
maybe PHP has a function which would convert line breaks to " " (and etc.)? It is needed when sending email from web form.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved