Hello all. All I really want to do is add slashes to my content. I want a user to be able to input data using HTML into my database. Also, if a user doesnt use HTML, I want the line breaks to change to HTML breaks.
That all works.
The problem is that if I use this code:
<?php
class convertText{
var $data;
var $result;
function inputData($text){
$this->data = $text;
$this->data = rtrim($this->data);
$this->data = nl2br($this->data);
$this->data = addslashes($this->data);
$this->result = $this->data;
return $this->result;
}
function outputData($text){
$this->data = $text;
$this->result = stripslashes($this->data);
$this->result = str_replace("<br />", "<br>", $this->data);
return $this->result;
}
}
?>
And input this data:
This is a test document. I will try HTML by bolding <b>this text</b>. "This should be in quotation marks."
2 line breaks.
The end.
I get this output:
This is a test document. I will try HTML by bolding this text. \"This should be in quotation marks.\"
2 line breaks.
The end.
How can I get rid of those frickin extra slashes?
Any help would be great.