Jump to content


This topic is now archived and is closed to further replies.


Database error

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

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.


Share this post

Link to post
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.

Share this post

Link to post
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
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

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.


Share this post

Link to post
Share on other sites


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.