You are here: I'm confused « All PHP « IT news, forums, messages
I'm confused

Posted by _Raven on 08/17/06 14:38

I am getting an error when adding info to table. I am getting mysql error
for duplicate entry.
The column is a unique one, but the data I'm inserting is unique from the
other entries.
The script WILL insert the new data into the table, but it will say that the
data is already there???
I get mysql error 'duplicate entry for key 2'. I have even tried entering
garbage for key 2, stuff like 'iusfoidsousussusdiudsi'
and I still get dup key error (but it adds it anyways??)

mysql_affected_rows() returns -1.

I don't understand what I'm doing wrong.

$sql = "INSERT INTO mytable (uid,name,state) VALUES (1,'joe','texas')";
$query = mysql_query($sql);
if(!$query){
$message = 'failed. ERROR: ' . mysql_error() . ' SQL: ' . $sql;
}else{
$message = 'Data Added';
}

Now in the example above, joe is not in the table, nor is any name there
even similar to joe.
The query will be successful, but I still get the duplicate entry error?
grrrrrrr

Any help would be appreciated!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация