Ich habe ein Datenbankproblem, bei dem ich Integritätseinschränkungsverletzung erhalte: 1062. Ich habe einige Dinge ausprobiert, aber es hat nicht funktioniert, jetzt frage ich dich Leute, um zu sehen, ob ihr mir helfen könnt.Integritätseinschränkungsverletzung: 1062 Doppelter Eintrag '1' für Schlüssel 'PRIMARY'
elseif($action == 'add') {
if($_POST['create'] == true) {
$title = $_POST['txtTitle'];
$txtParentCategorie = $_POST['txtParentCategorie'];
$txtContent = $_POST['txtContent'];
if($txtParentCategorie == "niks") {
$txtParentCategorie = NULL;
$chkParent = 1;
$order_count = countQuery("SELECT categorieID FROM prod_categorie WHERE parentID=?",array(1));
$order = $order_count + 1;
} else {
$chkParent = null;
$order_count = countQuery("SELECT categorieID FROM prod_categorie WHERE parentID is not NULL");
$order = $order_count + 1;
}
Query("INSERT INTO prod_categorie (categorieID, parentID) VALUES (?, ?)", array($chkParent, $txtParentCategorie));
$inserted_id = getLastInsertId();
Query("INSERT INTO tekst (tabel, kolom, item_id, tekst, taalID) VALUES(?, ?, ?, ?, ?)", array('prod_categorie', 'categoriename', $inserted_id, $title, $lang));
Query("INSERT INTO tekst (tabel, kolom, item_id, tekst, taalID) VALUES(?, ?, ?, ?, ?)", array('prod_categorie', 'content', $inserted_id, $txtContent, $lang));
$languages = selectQuery("SELECT taalID FROM taal WHERE taalID!=?",array($lang));
}
wenn i laufe dies die erste INSERT INTO leider nicht in irgendwelchen Daten füllen und diesen Fehler geben: Integrität-Randbedingungsverletzung: 1062 doppelte Eintrag ‚1‘ für die Taste ‚primären‘ gab es bereits eine primäre Taste 1 in Dort. aber es ist auf automatischem Zuwachs. in der Tekst-Tabelle erhält die item_id einen 0-Eingang.
Javascript:
$('.btnAddCategorie').click(function(){
if(busy != 1){
busy = 1;
var error = 0;
var gallery = $('select[name="gallery_dropdown"]').val();
if($('input[name="txtTitle"]').val() == ''){
error = 1;
alert('Het titel veld is nog leeg');
$('input[name="txtTitle"]').focus();
}
if(error != 1){
$('.content_load_icon').html('<img src="../../includes/images/layout/load_small.gif" />');
var content = $('#cke_ckeditor').children().children().children()[3].contentWindow.document.childNodes[1].childNodes[1].innerHTML;
$.ajax({
url: '../../action/ac_productbeheer.php?a=add',
type: 'POST',
data: {txtTitle: $('input[name="txtTitle"]').val(), txtForm: $('select[name="txtForm"]').val(), customGalTitle: $('.txtCustomGalleryTitle').val(), gallery_dropdown: gallery, txtParentCategorie: $('select[name="txtParentCategorie"]').val(), txtContent: content, txtMeta: $('.txtMetaDesc').val(), create: true},
success: function(data, textStatus, xhr) {
$('.content_load_icon').html('');
$('.txtContentConsole').html('Product succesvol opgeslagen!').show().delay(2000).fadeOut(200);
busy = 0;
saved = 1;
window.location = '../../modules/productbeheer/index.php';
},
error: function(xhr, textStatus, errorThrown) {
$('.content_load_icon').html('');
$('.txtContentConsole').html('Fout bij opslaan! Probeer het later nog een keer.').show().delay(2000).fadeOut(200);
busy = 0;
}
});
} else {
error = 0;
busy = 0;
}
}
});
html:
<a class="btnAddCategorie"><img name="btnOpslaan" src="/'.CMS_ROOT.'/includes/images/layout/opslaan.png" /></a><span class="content_load_icon"></span><span class="txtContentConsole"></span>
Hoffnung mir hier jemand helfen kann, auf. schon viel Dank im Voraus. :)
Wir können Ihnen nicht helfen, es sei denn, Sie zeigen uns die create-Anweisung für die fragliche Tabelle. –
Sie haben drei Einsätze. Kannst du sagen, welcher fehlschlägt? – asantaballa
Versuchen Sie, einen Wert in Ihren Primärschlüssel einzufügen? Wenn ja - nicht (in der Tekst-Tabelle erhält die item_id eine 0-Eingabe.) -> Veröffentlichen Sie auch Ihre Tabellendefinition – AgRizzo