Click here to Skip to main content
16,021,911 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
First in our system it would not be possible for a user to do this, but a bot (the bot is from facebook from what I can tell from their "vanity" ip) is hitting a page that's missing data in a column that is the primary key but still inserts a row.

This creates problems. One such problem is when I insert a row after their insert, the id inserts that out of order ie, next auto increment should have been 1000 but used id 990. I also saw some bad data echo in the PHP program pulled from the mysql db.

Does anyone know how this can insert with a missing primary and generally how a row can insert out of order? Or any other useful things to consider.

What I have tried:

I added additional code to fail for missing info when trying to insert
Posted

1 solution

You didn't mention anything about the table structure your inserting records into.

Typically, the primary key is setup to be generated by the database engine when a record is inserted into a table, so no primary key should be specified in that case.

Now, if you have code that is specifying the primary key, it sounds like you're just storing an integer value in a field you're calling the primary key and either letting the user specify the key or your code is generating that value, both are a really bad idea.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900