View Full Version : Problem with breaking lines(nl2br)

07-19-2008, 03:28 PM
$comment = nl2br(checkinput($_POST['comment']));

I use this to try and add in the breaklines that a user does without adding the <br> codes.

But this just doesn't seem to be putting in the linebreaks :X

My checkinput function does this:

function checkinput($value) {
$value = mysql_real_escape_string($value);
$value = strip_tags($value);
$value = htmlentities($value);
//Scan for bad words. GO GO GO

//our smilie codes

$smilie_codes = "java, script, javascript";

//our smilie images

$smilie_images = "-blocked-,-blocked-,-blocked-";

//set our smilie codes into an array

$smilies = explode(", ", $smilie_codes);

//set our smilie images into an array

$images = explode(", ", $smilie_images);

$amount = count($smilies)-1; //we'll decrease it by 1, since all array's start with the number [0] and not [1], and counting of them DOES start by1, so if we want to know the last array number string, we gotta decrease it by 1


$value = str_replace($smilies[$i],$images[$i], $value);


return $value;

any help?

07-19-2008, 04:12 PM
I think the problem you'r having is that you'r "scan for bad words" it's deleting all you'r html content, thats why nl2br doesn't work