Odd issue with HTML in MySQL and page breaks

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vigile
    Senior Member
    • Oct 2000
    • 376

    Odd issue with HTML in MySQL and page breaks

    I am in the process of converting a non-forum portion of my database between two CMS systems and long story short, I am having an odd problem with line breaks.

    If you look at this page here: http://pcper.com/article.php?aid=651&type=expert

    and view the source code you'll see a section of text that starts with "graphics card testing" that has "breaks" in the code in the source, but those breaks do NOT show up when viewing the page - which is what I want.

    Looking at the DB in phpMyAdmin, this is what I see for that code:

    HTML Code:
    <em><span style="color: rgb(0, 86, 172);">Graphics card testing has
    become the most hotly debated issue in the hardware enthusiast
    community recently.&nbsp; Because of that, testing graphics cards has become
    a much more complicated process than it once was.&nbsp; Before you might
    have been able to rely on the output of a few synthetic, automatic
    benchmarks to make your video card purchase, that is just no longer the
    case.&nbsp; Video cards now cost up to $500 and we want to make sure that we
    are giving the reader as much information as we can to aid you in your
    purchasing decision.&nbsp; We know we can't run every game or find every bug
    and error, but we try to do what we can to aid you, our reader, and the
    community as a whole.</span></em></p>
    <p align="left"><em><span style="color: rgb(0, 86, 172);">With that in mind, all the
    benchmarks that you will see in this review are from games that we
    bought off the shelves just like you.&nbsp; Of these games, there are two
    different styles of benchmarks that need to be described.</span></em></p>
    <p align="left"><em><span style="color: rgb(0, 86, 172);">The first is the
    "timedemo-style" of benchmark.&nbsp; Many of you may be familiar with this
    style from games like Quake III; a "demo" is recorded in the game and a
    set number of frames are saved in a file for playback.&nbsp; When playing
    back the demo, the game engine then renders the frames as quickly as
    possible, which is why you will often ...
    There appear to be odd "breaks" in the code there (after "has", after "enthusiast", etc) that is causing the import into the new DB structure to produce HTML that looks like this:

    HTML Code:
    <em><span style="color: rgb(0, 86, 172);">Graphics card testing has<br />
    become the most hotly debated issue in the hardware enthusiast<br />
    community recently.&nbsp; Because of that, testing graphics cards has become<br />
    a much more complicated process than it once was.&nbsp; Before you might<br />
    have been able to rely on the output of a few synthetic, automatic<br />
    
    benchmarks to make your video card purchase, that is just no longer the<br />
    case.&nbsp; Video cards now cost up to $500 and we want to make sure that we<br />
    are giving the reader as much information as we can to aid you in your<br />
    purchasing decision.&nbsp; We know we can't run every game or find every bug<br />
    and error, but we try to do what we can to aid you, our reader, and the<br />
    community as a whole.</span></em></p>
    My question is what are those "invisible breaks" in the database and how can I get rid of them somehow (either in PHP or by running a find/replace on the current DB) to prevent this odd formatting error.

    Thanks!!
  • Lats
    Senior Member
    • Mar 2002
    • 3671

    #2
    Viewing the first block of code in my editor, ultraedit, I see end of line characters where the break tags appear in the second block of code.

    You'll need to remove those - either \r, \n or both depending on the character set.
    Lats...

    Comment

    • Vigile
      Senior Member
      • Oct 2000
      • 376

      #3
      I have tried to str_replace \r\n or each individually, but it would appear those characters don't appear until I use the mysql_real_escape_string() function on the code. I know I NEED to run that function in order for the INSERT queries to run correctly, but I can't seem to find a way to strip those page/line breaks that exist in the code in the DB before hand. I tried this:

      PHP Code:
      $text preg_replace'/\p{Z}/u'' '$text ); 
      But that seems to result in an error or something as it clears out ALL my text.

      Comment

      • Lats
        Senior Member
        • Mar 2002
        • 3671

        #4
        Depending on how you proceed, you may find the trim, or rtrim command helpful...


        Lats...

        Comment

        Related Topics

        Collapse

        Working...