Jump to content

[SOLVED] UPDATE Problem - inputting integers separated by comma's


MasterACE14

Recommended Posts

Try typing it in with an escape in front of the comma: weapons\,2

 

By the way, you are breaking an awfully BIG MySQL rule here, and that is: NEVER use commas in fields to separate data items. If you need to do this, then your database is NOT properly normalized. Commas should only be allowed in text fields where it is a part of normal text. You should address this issue, and then you won't have this problem. MySQL was designed to take a comma separated list of items and store them as nuclear values with relationships. It wasn't designed to store comma separated items as a whole. Defeats the whole architecture!

 

PhREEEk

Link to comment
Share on other sites

how should I separate data in the same column then? basically this is for my text game, and when a user buys a weapon, I want it to add the ID of the weapon to that column, so if I cant use a comma(or shouldnt use a comma), how should I go about this?

 

Just adding the 2 should be sufficient.

 

We can say that weapon = '2'

 

whereas your query is suggesting:

 

weapon = 'weapon => 2', which is redundant.

 

As far as normalizing your database to better serve your data needs, that's almost impossible without knowing exactly what your game does and how the database is constructed to begin with. All I can tell you is that if your database is properly normalized, then your querys will be easier and more logical, and your code will be likewise.

 

From what I can see, it seems apparent that you should have a table named `weapons`, which have ID numbers and their own unique properties (such as weapon NAME, etc..).  One such weapon might have an ID of '2'. If UserID '1' has weapon '2', then there's a relationship we can act upon, either by viewing it, modifying it, or deleting it.

 

PhREEEk

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.