- Messages
- 562
- Reaction score
- 1
- Points
- 18
I'm not sure how to explain this, but I'll start with the problem, how I resolved it and the summarized question.
So to make things short, I run a little php game (still in development) where players fight each other. Battle information goes to a table called "battle", which is kept afterward because I store the logs for archives that can be consulted later on.
To build it up, I first get the info for each opponent in their "users" table, then construct a $battleid used to identify the fight and put all this info in my "battle" table, where $battleid will serve as a secondary id.
The problem: At some point, everytime a battle was started, the script would insert the information in "battle", but with a $battleid different than the one it had constructed. For example, for a given fight the $battleid should have been 123456, but the info was inserted under, say, 336655. Then, when the battle was supposed to carry on, it looked for the info associated to 123456 and found none, prompting a page empty of any database results.
Even weirder, 336655 (in my example) was always used, regardless of who was involved (which is supposed to influence greatly my $battleid).
So... after much searching, I solved the problem by truncating my "battle" table. After that, the script started working fine again.
My hypothesis is that the table may have reached a certain limit, but it merely had 1600 entries (okay it's not just a few, but compare that this forum's members entries and I bet it's many times bigger). So I would doubt this is the reason, but I can't think of any other explanation for a problem that is solved by truncating the table :nuts:
I'm asking 'cause I don't want it to happen again and having to flush my entries everytime, losing my archives in the process. Any tips will be greatly appreciated, although I'm not in a rush.
Edit:
Ok I just found out that setting my "battleid" column to INT instead of VARCHAR is what caused the problem. You may close this thread.
So to make things short, I run a little php game (still in development) where players fight each other. Battle information goes to a table called "battle", which is kept afterward because I store the logs for archives that can be consulted later on.
To build it up, I first get the info for each opponent in their "users" table, then construct a $battleid used to identify the fight and put all this info in my "battle" table, where $battleid will serve as a secondary id.
The problem: At some point, everytime a battle was started, the script would insert the information in "battle", but with a $battleid different than the one it had constructed. For example, for a given fight the $battleid should have been 123456, but the info was inserted under, say, 336655. Then, when the battle was supposed to carry on, it looked for the info associated to 123456 and found none, prompting a page empty of any database results.
Even weirder, 336655 (in my example) was always used, regardless of who was involved (which is supposed to influence greatly my $battleid).
So... after much searching, I solved the problem by truncating my "battle" table. After that, the script started working fine again.
My hypothesis is that the table may have reached a certain limit, but it merely had 1600 entries (okay it's not just a few, but compare that this forum's members entries and I bet it's many times bigger). So I would doubt this is the reason, but I can't think of any other explanation for a problem that is solved by truncating the table :nuts:
I'm asking 'cause I don't want it to happen again and having to flush my entries everytime, losing my archives in the process. Any tips will be greatly appreciated, although I'm not in a rush.
Edit:
Ok I just found out that setting my "battleid" column to INT instead of VARCHAR is what caused the problem. You may close this thread.
Last edited: