Jump to content
  • 0

MySQL Binary


Mystery

Question


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Not sure where to post this.. but I have a simple question people might know and I don't.. In a MySQL table, you can add a BIN column also known as a Binary column. I was just wondering, how exactly can you translate simple text to binary so that the MySQL Table reads it? I've tried uploading .bin files, etc. but I can't seem to get it to work.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Anyone know?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

In PHP you can use addslashes with fread to convert a binary file into a string of characters that can be used in a SQL query to insert the binary file.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Yeah uh.. I have no idea how to set that up o_o... Im not really a wizard when it comes to PHP.. (Complicated codes).

Edited by Mysterious
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Could you help elaborate a little further on how should I do those Brian? :/

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Thanks!! It seems promising so I'll try it out! Thanks a lot Brian!

Damn, I don't know how to add it to a specific column.. because what I have is an item_db but theres a description field that's in a binary field.

Basically, this is the structure of the table:

(`id`, `name_english`, `name_japanese`, `type`, `price_buy`, `price_sell`, `weight`, `attack`, `defence`, `range`, `slots`, `equip_jobs`, `equip_upper`, `equip_genders`, `equip_locations`, `weapon_level`, `equip_level`, `refineable`, `view`, `script`, `equip_script`, `unequip_script`, `Description`, `Description_IRO`, `Episode_Info`, `Droppers`)

`Description` is the Blob field.

Edited by Mysterious
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

What data are you storing in `Description` ?

If it's text, I think CHAR or VARCHAR data type would be better, or if it's longer then TINYTEXT, TEXT, MEDIUMTEXT, or LONGTEXT.

http://dev.mysql.com/doc/refman/5.5/en/blob.html

Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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...