dbutil->backup newline problem (\n) |
[eluser]dootzky[/eluser]
Hi guys, I've used database utility, and I'm using it for my users to quickly download and backup the entire MySQL database. And it works great. But now I have a problem - in my CMS, I have, for example, "Webpages" control, where users can edit their own webpages, in properly implemented FCK editor. That works great, everything is by the book, etc. And now, the problem - when ever I backup my database with dbutil class, I can import that database on my local Linux development server, but, FCK texts are getting bunch of "\n" characters all over the place, and it messes up everything in my CMS that uses FCK for editing (Webpages, Email Templates, etc.) here's my code, it's rather straightforward and simple: Code: $folder = 'db_backup/'; I think that's pretty simple, right? :| Oh, yes, one more thing that could be helpfull for you to know - when I export the database in the old, classic way from live server, from CPanel->phpMyAdmin->Export, and then I import that file on my server - it works flawlessly. Of course. The only problem here in my thread is that I'm getting "\n" overhead, and I don't think that dbutil class should insert newline characters in SQL VALUES, but only in SQL commands... ? Can anyone tell me where I'm mistaken? Or at least point me to some reading materials? (I've already read: http://ellislab.com/codeigniter/user-gui...ities.html , thanks ) Thanks for your time and effort, dootzky p.s. please see attachment picture for more graphical explanation...
[eluser]TheFuzzy0ne[/eluser]
I would suggest you try using the constant PHP_EOL instead - see if that makes a difference.
[eluser]dootzky[/eluser]
Hi, thanks for your reply, but it didn't solve the problem. Everything is still the same. I think the problem is not at all in the new line character format, the problem is that it puts a "newline character" (which ever that may be), in wrong places. The dbutil should never place aditional newline characters in table CONTENT, right? Is there something else that I could do here? Thanks again for your time and help, regards, dootzky
[eluser]TheFuzzy0ne[/eluser]
Sorry, I'm really confused. Where does FCKEditor come into this again? I don't understand why your code uses force_download, but you are displaying the problem via FCKEditor.
[eluser]dootzky[/eluser]
Hi again, I'm not sure what's confusing you, but please allow me to give you more code examples, that should clear things right up: this is HTML code from my source-view in Firefox, or from "Source View" in FCK (in my CMS editing..) Code: <div class="home_promo_bottom_cnt" style="margin-right: 10px;"> everything is good and clear here, right? cool. this is exactly how it's saved in my live-server database, and everything is great. yay. Now, here is where the problem arises: 1) I export the entire MySQL database using the code given above, with DBUTIL class 2) I save that exported file on my desktop, and I do IMPORT on my local database 3) and this is what I get - corrupted data in every database field which was edited with FCK here's a code example of corrupted data, exported with DBUTIL class: Code: INSERT INTO scms_webpages (id, title, subtitle, body, ordering, active, title_eng, title_rus, title_ukr, subtitle_eng, subtitle_rus, subtitle_ukr, body_eng, body_rus, body_ukr) please notice bunch of "\\n" characters, which DOESN'T EXISTS in live server database!! so the conclusion is - on live DB - everything is great - once I do DBUTIL export, and then I look into the exported file - I notice there are bunch of "\\n" characters which are NOT supposed to be there, at all. they don't even exists in the real DB on live server. do you see the problem now? DBUTIL class is adding \\n characters without any reason, and as far as I can tell - it's adding those characters only in DB fields which were edited by FCK editor. do you think that this is FCK issue? should I perhaps report a bug on FCK development site? again, thanks for your time and effort. I hope we'll get to the bottom of this. best regards, dootzky
[eluser]TheFuzzy0ne[/eluser]
Sorry for the delay in my reply. I've had some serious PC/server/network issues, and spent the last three days trying to resolve them... Can you confirm that when you backup the database via the normal method (be it PHPMyAdmin, or over the CLI), the you don't get the same problem? Those \\ns appear within the text (not just at the end), and therefore must be in the database like it, so it's probably an issue with FCKEditor.
[eluser]TheFuzzy0ne[/eluser]
OK, I think I might have inadvertently stumbled across the solution to your problem (or rather part of it). Code: $str = "this\nis\na\ntest"; It would appear that your text is being escaped twice.
[eluser]dootzky[/eluser]
Hi Fuzzy dude! Thanks for replying and not forgetting me. And don't worry about the long wait, you don't have an "obligation" to help me, it's just your good will and helping spirit, so I appreciate that. Really. Alright, so, basically - it's either that FCK is causing this weird bug, but I think then you would be familiar with this bug much better, because other people would complain too, right? Almost everybody is using FCK these days for rich text formating in their CMS. And if FCK is not to blame, then I gotta check out this other thing you found - double "mysql_real_escape_string" command. I gotta dig deep in the code now, because I must check out entire dbutil lib now. I'll get back to you soon with results, hopefully with a solution too. Thanks again for your time and effort mate. cheers, dootzky |
Welcome Guest, Not a member yet? Register Sign In |