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?
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.
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.
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.