Carriage Return In mySQL TEXT type field
Carriage Return In mySQL TEXT type field
![scanmaster](https://secure.gravatar.com/avatar/4e51ca73252c36f5ff3e170d5d3c788a/?default=https%3A%2F%2Fvanillicon.com%2F4e51ca73252c36f5ff3e170d5d3c788a_200.png&rating=g&size=120)
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
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
This discussion has been closed.
Replies
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
I'll have a go at that and try it tomorrow.
Steve