Problems with writing to flat file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adamjblakey
    New Member
    • Jan 2008
    • 133

    Problems with writing to flat file

    Hi,

    I have a script which writes to a flat file and breaks it up like so:

    [PHP]
    <?php
    $dblink="./data.db";
    $moddb = file($dblink);
    foreach($moddb as $data_line){
    list($id, $catid, $image, $title, $desc) = explode('|', trim($data_line ));
    ?>
    [/PHP]

    The problem is that when i add this to the database it puts the description over separate lines so it classes one entry as about 5 different ones.

    How can i get around this, is there something i can do when adding the description to the database or is there a different way to display.

    Cheers,
    Adam
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    I assume that $desc is stored into 1 column of the table, but that it only splits in several lines in that column, yes? When so, you still have newline characters in the description data.
    When not, please explain, because then I do not understand the question.

    Ronald

    Comment

    • adamjblakey
      New Member
      • Jan 2008
      • 133

      #3
      Originally posted by ronverdonk
      I assume that $desc is stored into 1 column of the table, but that it only splits in several lines in that column, yes? When so, you still have newline characters in the description data.
      When not, please explain, because then I do not understand the question.

      Ronald
      Yes you are correct.

      The data is store like e.g.:

      1|8|image.jpg|T his is the Title|This is the description

      The problem is that if i add a large description it splits it on to multiple lines so that it reads description as multiple entries when it is only one.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Before you add the dscription to the file you must remove the newline characters ("\n") from it, because the FILE() command, upon reading the text again, will split its entries accoding to that newline character.

        Ronald

        Comment

        Working...