发布错误
调试模式
SQL错误:1062键“ PRIMARY”的条目“ 0”重复
INSERT INTO nuke_bbtopics(topic_title,topic_poster,topic_time,forum_id,topic_status,topic_type,topic_vote)值(“测试”,39、1541598387、22、0、0、0)
行:227 文件:functions_post.php
答案 0 :(得分:0)
您遇到的问题不是查询,而是表顺序。只需重新排序自动增量即可。
答案 1 :(得分:0)
您的自动递增未排序。检查您在#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct car {
char name[30];
int quantity;
};
void increaseSize(int *cap, int size, struct car **carArray) {
printf("cap = %d size = %d\n", *cap, size);
*cap *= 2;
printf("cap x 2 = %d\n", *cap);
struct car *newCarArray = (struct car * ) malloc(*cap * sizeof(struct car));
memcpy(newCarArray, carArray, sizeof(struct car));
free(*carArray); // If I free old carArray here, it will give incorrect results. How can I release/clear/delete/free the memory of the old array here?
carArray = &newCarArray;
printf("increased cap = %d size = %d\n", *cap, size);
}
void printArray(int cap, int size, struct car *carArray) {
printf("Capacity = %d, Size = %d \n", cap, size);
for(int i = 0; i < size; i++) {
printf("Car %d, Name: %s, Quantity: %d\n", i, carArray[i].name, carArray[i].quantity);
}
}
int main() {
int cap = 2;
int size = 0;
struct car *carArray = (struct car *) malloc(cap * sizeof(struct car));
struct car car_0 = {"Corolla", 5};
carArray[0] = car_0;
size++;
struct car car_1 = {"Accord", 8};
carArray[1] = car_1;
size++;
printArray(cap, size, carArray);
increaseSize(&cap, size, &carArray);
struct car car_2 = {"Forte", 3};
carArray[2] = car_2;
size++;
printArray(cap, size, carArray);
free(carArray);
return 0;
}
上是否有PRIMARY_KEY
。