Page 1 of 3

My DB Is skipping a few entries

Posted: Mon Aug 20, 2007 1:03 pm
by legend986
I've written a small registration script that registers members. When I look at the list from the database, I see that a numbers have been skipped in the primary id field... It displays something like:

1
2
3
5
6
7
13
14

I don't understand. Did I loose a few registrations or something? :(

Posted: Mon Aug 20, 2007 1:10 pm
by TheMoose
Are you sure another script didn't delete them, or that your script is closed to SQL injection?

Posted: Mon Aug 20, 2007 1:12 pm
by legend986
No, there is no other script that can delete that because there's no code at all in the first place on my server to do that. And as per SQL Injection, I'm not aware of it :(

Posted: Mon Aug 20, 2007 1:57 pm
by superdezign
Are people allowed to delete accounts or have you ever deleted accounts (test accounts, possibly?)?

Posted: Mon Aug 20, 2007 2:00 pm
by legend986
No they are not allowed to...and as far as the test accounts are concerned, I tested only on my local server and even if I tested it on the real server, I did it and then dropped the table.

Posted: Mon Aug 20, 2007 2:05 pm
by superdezign
It's either the result of glitchy code or SQL injection (which also implies glitchy code). Where you create user accounts, do you affect the primary key at all in the query?

Posted: Mon Aug 20, 2007 2:08 pm
by legend986
Well, I usually don't touch my primary key at all... I just used it as an id because it is unique. I just keep inserting new registrations into the key. Even now, a few hours back, it skipped a number.. Could it be some problem from the host side?

Posted: Mon Aug 20, 2007 2:15 pm
by superdezign
.. I don't see that making sense. Somewhere, something weird is happening. If you have a central database class, start logging all of the queries that you make.

Posted: Mon Aug 20, 2007 2:19 pm
by legend986
I'm a newbie so I don't go into the depths of programming yet :( I don't have a central database class... I'll explain the process...

Someone registers... Their entry is entered into the database and at the same time, another query is run which uses a separate library called IPBSDK, Invisions SDK for registering members. But that query is such that the registration is independent of whether that query was run or not...

Posted: Mon Aug 20, 2007 2:23 pm
by superdezign
... That's not something I could help debug from here. You'll really need to have some way of tracing your queries to find out which query is causing the problem.

Posted: Mon Aug 20, 2007 2:25 pm
by legend986
Yeah I understand :( Is there a way I could do that?

Posted: Mon Aug 20, 2007 2:34 pm
by superdezign
Do some searches to see if MySQL has a query log. It likely does.

Posted: Mon Aug 20, 2007 2:36 pm
by TheMoose
Are the ID numbers coming from that specific tables auto increment, or are they being generated from IPBSDK?

Posted: Mon Aug 20, 2007 2:36 pm
by legend986
Yeah there are some log files but then they all contain errors related to my Invision board and not my script... And yeah, there's an auto_increment for that column...

Posted: Mon Aug 20, 2007 2:43 pm
by RobertGonzalez
Can you post your insert code. Since there is no way to edit or delete, everything related to your problem should be in the insert.

Also, post your table structure.