+ Reply to Thread
Results 1 to 4 of 4

Thread: Strange SQL Problem

  1. #1
    gavicus's Avatar
    gavicus is offline x10Hosting Member gavicus is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    9

    Strange SQL Problem

    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?

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Strange SQL Problem

    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.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    gavicus's Avatar
    gavicus is offline x10Hosting Member gavicus is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    9

    Re: Strange SQL Problem

    Ack! That's it! Thanks for your help.

  4. #4
    nirajkum is offline x10 Sophmore nirajkum is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    161

    Re: Strange SQL Problem

    if you want to insert the next record with the same primary key ... insert would fail ..

+ Reply to Thread

Similar Threads

  1. My sql Problem...Not responding...
    By admintwo in forum Free Hosting
    Replies: 2
    Last Post: 06-01-2008, 10:38 AM
  2. sql database does not restore
    By softwork in forum Free Hosting
    Replies: 3
    Last Post: 05-20-2008, 06:47 AM
  3. Sql?
    By SLIForum in forum Scripts & 3rd Party Apps
    Replies: 4
    Last Post: 12-03-2007, 01:17 AM
  4. Hmm. Strange problem...
    By B7u3A in forum Off Topic
    Replies: 3
    Last Post: 08-08-2005, 01:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers