-4

help my proplem when insert in tabel mysql my structure table: enter image description here

when insert in table error here... enter image description here

please solution..

Iyes boy
  • 305
  • 3
  • 6
  • 1
    Please provide the insert query in your question. The image is not giving the full query. – Gunaseelan Jul 13 '16 at 07:05
  • remove idx from your query, because it is an autoincrement – Jens Jul 13 '16 at 07:06
  • Remove the column first and then create again – Gulmuhammad Akbari Jul 13 '16 at 07:06
  • @Jens my query "INSERT INTO siswa_sekolah SET id_sekolah = '".$_POST['id_sekolah']."' , user_id = '".$_POST['user_id']."', id_kelas = '".$_POST['id_kelas']."' , id_rombel = '".$_POST['id_rombel']."', id_tahun_ajar = '".$_POST['id_tahun_ajar']."' "; im not use idx in query – Iyes boy Jul 13 '16 at 07:46
  • Insert into .... set ... is not valid Syntax. Also the query is not the same as in your screenshot – Jens Jul 13 '16 at 07:48
  • thanks @Jens problem solved – Iyes boy Jul 13 '16 at 08:09
  • Screenshots are almost always the wrong way to present this information. For database questions please post the query you're trying to execute *in full* and **as plain text**. This helps people because they can cut, paste, and make corrections. For the schema use the result of `SHOW CREATE TABLE` which gives the right level of technical detail. – tadman Jul 13 '16 at 08:37

3 Answers3

0

This error says, the new record has an existing record into the table you are working. Please check your primary key before inserting it as a new record.

Hope it helps you.

Vijunav Vastivch
  • 4,153
  • 1
  • 16
  • 30
0

It tells you that IDS0000702 is already used in your table. Make sure the column that holds that kind of id (which I guess the user_id column) is not unique (if not intended to save data uniquely):

//if you want to change your "suspecting" column's attribute
ALTER TABLE mytable DROP INDEX mycolumn
rhavendc
  • 985
  • 8
  • 21
  • i try to "ALTER TABLE `siswa_sekolah` DROP INDEX `user_id`" the comment "#1091 - Can't DROP 'user_id'; check that column/key exists " – Iyes boy Jul 13 '16 at 07:43
  • @Iyesboy Then maybe I was wrong of assuming that suspecting column is `user_id`. I dunno know the whole of your table. Why not try the other id-holding columns, specially that `fkss` (which is cannot be seen in the photos you've posted) – rhavendc Jul 13 '16 at 07:49
0

thanks all.... PROBLEM SOLVED two step for resolved problem:

  1. Show index in table query = SHOW INDEX FROM <table_name>;
  2. Delete index in table = ALTER TABLE <table_name> DROP INDEX <index_name>;

im found the index in user_id "fkss" thanks any answer.. :) link refernce

Community
  • 1
  • 1
Iyes boy
  • 305
  • 3
  • 6