Forum posts only take up half a line

I have made my own forum. Sometimes people post and they seem to cut and paste from somewhere else. Their posts only take up half a line. It makes posts unreadable eg

. I tried stripping out all chr(13) and chr(10) but that did not work in every occasion. Why does this not work. I tried making a program to read the characters but at the crucial points it seems to be chr 32 or spaces.

What code are you using to put the data into that box? It looks like the lines are being broken early by <br>'s, and so wont fill-and-wrap.

Yes thats a good point. There are breaks in there. But I read the whole lot from the database into a string. Then I went through the entire lot reading each character using ord(). All that turned up was spaces (32’s).

On other posts it works normally using the same code.

str_replace any <br>'s in the string with ‘’ (empty). Should remove them from the string, which will leave you with a solid block of text. <br> is not a character code - your ord reader would read 60,98,114,62 - <,b,r,>

Hi starlion

I have this text and I know what the problem is now… The replace works but it is not saving to the database. I select OK. But then I try to update and it does not work. I have come across this problem before. I write code which has been cut and pasted and seems to work fine. yet database code seems not to work… why? its not the code( I am sure)… I have rewritten it correctly.

$result = mysql_query("SELECT dream,background FROM list WHERE postnumber=$id");

if (!$result) {
    $stringg='Could not run query:' . mysql_error();
    exit;
}
$row = mysql_fetch_row($result);

$dreer=$row[0];
$bg=$row[1];


$bg = str_replace(chr(13), " ", $bg);
$bg = str_replace(chr(10), " ", $bg);

$bg="$bg add this"; // I have added some text to show that the field has been updated


$result1 = mysql_query("UPDATE list SET background = '$bg' WHERE postnumber=$id");

The breaks do not appear in the original block of text. I add the breaks in myself with code WHILST the forum page is being opened. I did that because returns do not seem to show up in html so when people type in returns in forms I replace these with breaks.

But some people cut and paste from some other source. So too many short lines appear. I think I know what the problem is now. Its just database programming is so finicky. I cut and paste some code and merely replace the name of the table and the field to be changed. Yet it doesn’t work.