PDA

View Full Version : cant add more than 1 value


flipmenus
6-24-07, 03:10 PM
for some reason when i try to enter data from the same username it wont add it. if i enter data from a different username it goes through. here is the code...any suggestions? thanks

mysql_query("INSERT INTO stats_nutr VALUES (
'$username','$date','$meal1',
'$meal2','$meal3','$meal4',
'$meal5','$meal6','$calories1','$calories2','$calo ries3',
'$calories4','$calories5','$calories6')");

the error it says is: #1062 - Duplicate entry 'robinson' for key 1

flipmenus
6-24-07, 03:50 PM
problem was fixed when i dropped the index...is that going to cause me problems in the future? what is an index for?

MISOA
6-24-07, 03:56 PM
Or use UPDATE command

.{TM}.
6-24-07, 04:51 PM
was it a primary or unique index?
that was probably the reason

Neat Pete
6-24-07, 10:59 PM
It must have been a unique index, otherwise you would not get a message about 'dupicate'.

A primary index is unique by definition.

Required indexes should be a part of your database design. If you don't have a design, then there is no point in having any indexes.

If you are joining tables to build queries, then you will need indexes, except where the table contains only a few rows, say less than 50.