homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

phpmyadmin question about auto increment
problem regarding auto increment

Msg#: 4154770 posted 1:02 pm on Jun 18, 2010 (gmt 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,


brotherhood of LAN

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

Msg#: 4154770 posted 1:07 pm on Jun 18, 2010 (gmt 0)


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.


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

Msg#: 4154770 posted 1:20 pm on Jun 18, 2010 (gmt 0)

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.


Msg#: 4154770 posted 1:38 pm on Jun 18, 2010 (gmt 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,

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved