Jump to content

Strange characters � in mysqldump output


matd

Recommended Posts

Hi,

 

I\'ve written a backup script which saves the output from a mysqldump and then prompts the uers to save the file. I have this working perfectly on my test server which is running apache on windows xp. But on the live server which is linux based the contents of the saved mysqldump are different.

 

I get these characters in the file :-

 

 

The mysqldump i run here is fine and formatted correctly when i look at it in notepad and i can import it into mysql using phpmyadmin with no problems.

 

But when i look at the version i download from the live server it has in it and the formatting is all over the place and i get errors if i try and import it in phpmyadmin.

 

I\'m sure i have set the correct mime-type and the headers are correct too.

 

Any ideas why?

 

Any help would be grealty appreciated :D

Link to comment
Share on other sites

I had the same problem and discovered that it was a problem with carriage returns ® against newline (n). I don\'t remember how I did the fix but this may help you if you can tell us if the special characters are replacing the newline characters.

 

JP.

Link to comment
Share on other sites

Whoa! that was quick! :-)

 

Well, heres a sample of the dump :-

 

`nALTER TABLE admin DISABLE KEYS */; -- -- Dumping data for table \'admin\'; -- --

 

thats the first line of the code, it does seem to be a carriage return problem as when i pasted that line above it appeared as:-

 

`nALTER TABLE admin DISABLE KEYS */;

 

--

-- Dumping data for table \'admin\'

--

 

Wonder why it would be different or changes characters when the same script running locally here works perfectly.

 

Would it be a case of converting some characters after the dump has run then?

Link to comment
Share on other sites

i was just using Notepad which i thought would show the bare file and ignore any formatting chars.

 

I\'ll try and look at it in textpad...

 

Still leaves the problem that i can backup and restore a mysql database in windows but can\'t backup a mysql database in Linux and restore it on a Windows platform.

 

Will i need to convert the line endings or somthing?

Link to comment
Share on other sites

when saving a file, textpad allows you to choose whether the line endings should be windows or unix. code-wise... there is a unix script to do this but it has escaped me at the moment... you should also be able to parse it in php.

Link to comment
Share on other sites

mysqldump --opt -c -hlocalhost -u$user -p$password $database | unix2dos | gzip > \" . $backup_dir . \'/\' . $backup_file

 

By piping to unix2dos before gzip it converts all unix chars to dos / windows ones :-)

Link to comment
Share on other sites

You wouldnt happen to know how i can terminate output to the header i\'ve set that allows me to save the dump to file would you?

 

I have an index.php which has a button for backup. When backup is clicked it forwards the browser to backup.php where i set the header information for file saving and then echo the file.

 

The only thing is, after the file has been saved i\'d like to put a link on that page to direct them back to another page, but as the header has been set it just gets put in with the file being saved.

 

Is there someway of doing :-

 

header(\'Content-Disposition: attachment; filename=\"\'. $saveas_filename . \'\"\');

header(\'Cache-Control: must-revalidate, post-check=0, pre-check=0\');

header(\'Pragma: public\');

 

echo $dump_buffer;

 

<terminate output to file>

 

<continue with php and html for page content displayed to browser>

 

Help as always, is very much appreciated :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.