0

I send zipped data, which is done with LZW compression at the client side with js, to server. The problem is that the data becomes corrupted after saving it to database with SQL.

So my question is, what collation should i use, to accomplish that? (My current one is latin1-default collasion)

I already checked if the problem arrieses during the data transferring from client to server and vice versa by sending encoded data to HTTP-Server and sending(PHP-echo) it back immeadiatly without processing it. I could decode LZW properly. So it should definitely be a problem with the database.

More information about the schema: I only have a single table with a 3 cols. "data" is type of "BLOB". (I also tried TEXT). user_id is INT and type is VARCHAR.

This is how i save the data:

INSERT INTO svg.saved_data (user_id, data, type) VALUES ('".$user_id."', '".$data."', '".$type."');
tadman
  • 208,517
  • 23
  • 234
  • 262
A.B.
  • 2,374
  • 3
  • 24
  • 40

1 Answers1

0

I don't know what your platform is, but the link below gives you a general recipe in php. It has an example which should do what you need.

https://stackoverflow.com/questions/17/binary-data-in-mysql

Martin
  • 911
  • 7
  • 21
  • Note that [link-only answers are discouraged](http://meta.stackoverflow.com/tags/link-only-answers/info), SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Jan 21 '14 at 09:28
  • Understood, I'll keep it in mind next time, but the link is back to SO and the answer is directly related. In fact this question is a special case for a generic problem, I'm adding a pointer to the more general topic. And in this case the topic happens to be the answer. I.e. "LZW in SQL" => "binary in SQL". IMHO it's logical. And it's a well written answer on SO, I can try to recreate it, but I'll probably botch it. .... Thank you for the pointer. – Martin Jan 21 '14 at 09:41