Jump to content


Photo

Database error


  • Please log in to reply
2 replies to this topic

#1 rgoogs21

rgoogs21
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 April 2006 - 07:36 AM

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

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.

Ryan

#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 26 April 2006 - 07:40 AM

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.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 rgoogs21

rgoogs21
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 April 2006 - 07:56 AM

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.

Ryan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users