密钥'PRIMARY'的mysql erroDuplicate条目'1' [英] Mysql erroDuplicate entry '1' for key 'PRIMARY'

查看:59
本文介绍了密钥'PRIMARY'的mysql erroDuplicate条目'1'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

得到错误althogh表中没有记录

i需要在couse和seat table中插入clgid bt im gettig主键错误。



getting error althogh there is no record in table
i need to insert clgid in couse and seat table bt i m gettig error on primary key .

$query="insert into clgmaster (ClgId,ClgName,ClgAddrs,FeeAmt,CntNo,Email,Pwd) values ($id,'$clgnm','$addrs',$fees,$cntno,'$eml','$pwd')";

    $result = mysql_query($query);//Excecuting clg query

    echo $result."<br>";

    echo "helllo query <br>";
    if ($result)
    {
        echo "<br>You Have Successfully REGISTERED this Record!";

    }

    $fetchData=mysql_query("select * from clgmaster");

    while($data=mysql_fetch_array($fetchData))
    {
        $id1= $data['ClgId'];
        echo $id1;

        //echo $data['ClgId'];
        echo "<br>";


    }

    //  **** inserting data into course table ****

    $query1="insert into course (ClgId,CourseName) values ($id1,$course)";
    echo $query1;

            $result1 = mysql_query($query1);//Executing course query
            echo $result1;

            if(!$result1)
            {
                die(" <br> Mysql erro".mysql_error());
            }
            else
                echo " <br> record inserted successfully in course";

推荐答案

query = 插入clgmaster(ClgId,ClgName,ClgAddrs,FeeAmt,CntNo,Email, Pwd)值(
query="insert into clgmaster (ClgId,ClgName,ClgAddrs,FeeAmt,CntNo,Email,Pwd) values (


id,'


clgnm','


这篇关于密钥'PRIMARY'的mysql erroDuplicate条目'1'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆