Strange SQL Problem

gavicus

New Member
Messages
9
Reaction score
0
Points
0
I have an SQL table I can only insert to if its empty. In other words, with my code as it is, the table only holds one record at a time.

The table genre_lookup has 3 fields:
id: int, primary key
movie: int
genre: int

and the SQL command:
mysql_query(
'INSERT INTO genre_lookup (movie,genre) VALUES('.$movie_id.','.$genre_id.')'
);
only does anything if the table is already empty.

I'd offer more detail, but I don't really know what would help short of dumping all my code here.

Any ideas?
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
Even if ID is a primary key, if it's not set to autoincrement, you have to give it a value. So, make sure to autoincrement ID or give it a unique value.
 

nirajkum

New Member
Messages
159
Reaction score
0
Points
0
if you want to insert the next record with the same primary key ... insert would fail ..
 
Top