Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

phpmyadmin question about auto increment

problem regarding auto increment

1:02 pm on Jun 18, 2010 (gmt 0)

New User

5+ Year Member

joined:May 22, 2010
posts: 12
votes: 0

Hello All,

I have added a "custom field" in a third party open source application which is a number only field. I have it to track how many times a visitor visits a website.

The problem is that the field keeps returning "undefined" when the data is accessed. I am using a php script to add to the field which I have used in the past successfully so I know it is not the script.

I am thinking if I can go through the phpmyadmin and set the field to auto increment, this would fix the problem? But when I go into the database, I cannot find where to set it to auto increment?

Any help at all would be appreciated...

Thanks in advance,
1:07 pm on June 18, 2010 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 30, 2002
votes: 4


Is PHP saying the field is undefined? If so, that'll be because the field is not included in the query that's returning the data. You would have to locate the query in the PHP code and add the field in alongside the other fields returned.

To add auto increment, the field must be the primary key I believe, so you have to make the field a primary key and then click on "edit" for the field. If you hover over buttons in phpmyadmin you will get a tooltip saying what they do.
1:20 pm on June 18, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 19, 2002
votes: 15

ok, i might have misunderstood what you are trying to do...

auto increment will set a unique number into the auto_increment field every time a new row is inserted.

auto_increment is not designed to increase every time a row is updated.

additionally you can only have one auto_increment in each row (usually the primary key) so if you are using a third party database and have added a field to a table i'd be astonished if they haven't already got an auto_increment field as the primary key anyway, in which case making your field the new primary key could have an unexpected effect.
1:38 pm on June 18, 2010 (gmt 0)

New User

5+ Year Member

joined:May 22, 2010
posts: 12
votes: 0

Hey Guys...

This site is probably the most helpful and quick to respond out of the several I use for miscellaneous issues. Thank you both for the quick replies.

I have found the problem's solution. The reason the field was saying it was undefined is that when I imported the data from a .csv file, it did not contain that field. I thought the third party software automatically added it but I apparently was wrong. I added the field and re-imported the data and now my php script is working as expected.

Also, I now understand what the auto-increment is actually for. The learning curve is steep for me in this area but you guys and this site have made it MUCH easier.

Thanks again,