Carriage Return In mySQL TEXT type field

Carriage Return In mySQL TEXT type field

scanmasterscanmaster Posts: 2Questions: 0Answers: 0
edited January 2010 in Bug reports
Hi,

I'd like to start off by thanking you for such an awesome plugin! :D

The problem I have is that I'm bringing in a mySQL TEXT field into the datatable which is fine provided there's not a carriage return in the field (the datatable just shows "processing" and doesn't display any data). I checked out the JSON with jsonlint and it says "syntax error, unexpected TINVALID at line 27, Parsing failed". I've tried php addslashes to the column but that makes no difference.

Do you know know if there's a workaround for this?

Thanks!

Regards,

Steve

Replies

  • allanallan Posts: 61,642Questions: 1Answers: 10,093 Site admin
    Hi Steve,

    Yup - JSON is rubbish at text which spans more than one line since it results in invalid data. Javascript strings are a bit of a pain with this in general. One thing to note is that '\n' means nothing in white, it's just white space, so the easiest solution is to replace it using your server side process (str_replace or whatever). Another option if you want a line break in the display is to replace \n with
    .

    Hopefully that will do the trick for you.

    Allan
  • scanmasterscanmaster Posts: 2Questions: 0Answers: 0
    Thanks for your quick reply mate!!

    I'll have a go at that and try it tomorrow.

    Steve
This discussion has been closed.