Jump to content

Difficulty with structure of string


EchoFool

Recommended Posts

Hey

 

When i input to my database a message from a form that was typed into a text area - say there was paragraphs and gaps etc.. when the message is outputted at a later date the structure is lost and it is just a big chunk of text - this is happening for my forum posts but have no idea how to maintain the input structure upon output.

 

Is there a a function of some kind for this solution?

Link to comment
https://forums.phpfreaks.com/topic/199997-difficulty-with-structure-of-string/
Share on other sites

Sure heres an example:

 

 

INPUT FORM:

<?

function SQLskip($Var){
$Var =  mysql_real_escape_string(stripslashes($Var));
return($Var);
}

if(isset($_POST['submit'])){
$Message = SQLskip($_POST['letter']);

      // insert query here

}Else{
?>
<form method="POST" action="">

<textarea name="letter" class="textarea"> </textarea> 
<br><br>
<input type="submit" name="submit" class="button" value=""><br><br>
<a href="mail.php">Cancel Message</a><br>
</form>
<?php } ?>

 

OUTPUT:

//select query $QueryName
$row = mysql_fetch_assoc($QueryName);
echo nl2br($row['Message']);

 

Field in database message example has the structure:

http://i43.tinypic.com/sp887n.png

 

Actual outputs:

http://i42.tinypic.com/2mfiuxw.png

 

So the input is fine as the structure remains in the database - its the output that goes wrong.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.