Jump to content

Database error


rgoogs21

Recommended Posts

Hello I am new here and a little new to PHP and MySQL also. I have a site that was made with php and a mysql database and was recently moved to a new hosting service. Now whenever I add data to the database through my site I can do it the first time but after that I get this error

[code]Error in SQL query! MySQL: Duplicate entry '0' for key 1
[/code]

I figured out it has to do with the ID it gives each piece in the table it is in but I dont know how to set it to start at the number it left off on when it was at the old hosting. Any help will be greatly appreciated.

Ryan
Link to comment
Share on other sites

Sounds like when the database was ported over to the new provider and created the primary key wasn't set to auto increment. Just to confirm this, can you export the table in question and show it here please? I'm at work at the moment and can't remember how to make the key set to auto increment - I'm sure someone here will be able to help.
Link to comment
Share on other sites

Well it happens to be every table that I use let me get a table for you, I think this is what you want
[code]
Field    Type    Null    Default
id_program    smallint(6)    No    0
id_user    smallint(6)    No    0
nazwa    varchar(50)    No    
url    varchar(70)    No    
opis    text    No    
mail    varchar(30)    No    
forum    varchar(70)    No    
feedback    varchar(100)    No    
telefon    varchar(20)    No    
icq    varchar(30)    No    
data    date    No    0000-00-00
status    char(1)    No    
rating    float    No    0
min_payout    varchar(100)    No    
min_deposit    varchar(100)    No    
time_payout    varchar(150)    No    
referral    varchar(20)    No    
total    smallint(6)    No    0
comment    text    No    
exclusive    char(1)    No    
premium    char(1)    No    
blacklist    char(1)    No    
stormpay    char(1)    No    
egold    char(1)    No    
ebullion    char(1)    No    
goldmoney    char(1)    No    
netpay    char(1)    No    
intgold    char(1)    No    
moneybookers    char(1)    No    
alertpay    char(1)    No    
emo    char(1)    No    
paypal    char(1)    No    
other    char(1)    No    
uniclear    char(1)    No    
premium_no    tinyint(4)    No    0
[/code]

That is a table where people add their program to the database. I currently have around 21 and now it starts with the id_program of 0 and never moves

Wow I think I just figured it out. Thank you so much for pointing me in the right direction. If I need any more help I will be back. Thanks again.

Ryan
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.