My DB Is skipping a few entries

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

My DB Is skipping a few entries

Post 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? :(
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post by TheMoose »

Are you sure another script didn't delete them, or that your script is closed to SQL injection?
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post 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 :(
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Are people allowed to delete accounts or have you ever deleted accounts (test accounts, possibly?)?
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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?
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post 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?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post 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...
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Yeah I understand :( Is there a way I could do that?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Do some searches to see if MySQL has a query log. It likely does.
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post by TheMoose »

Are the ID numbers coming from that specific tables auto increment, or are they being generated from IPBSDK?
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post 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...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

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