SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    scarborough
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

    http://www.dreamsymbolism.info/forum...php?id=4446855

    . 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.

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    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.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    scarborough
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    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,>

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    scarborough
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    PHP Code:
    $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"); 

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    scarborough
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •