I have a table with ips and a count of the amount of times the ip accessed a certain page. I want to add one to the count if a row exists with the ip, otherwise create a row with the ip and set the count to 1.
I tried
INSERT INTO mytable (ip,count) VALUES ('" + ip + "',1) ON DUPLICATE KEY UPDATE count=count+1;
But ip isn't unique or primary, so it just keeps creating rows with the same ip. I tried making ip unique, but it won't let me. When I try to create a text column and make it unique, phpmyadmin says BLOB/TEXT column 'test' used in key specification without a key length
.
I'm alright with using two statements. How can I accomplish this?