2 Replies - 505 Views - Last Post: 18 June 2008 - 11:01 AM Rate Topic: -----

#1 kaps  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 31-May 08

Duplicate kye problem

Posted 18 June 2008 - 08:33 AM

hi frnds,

im trying to make a quiz which will run on my website, now problem is that..

i made a database and two tables , in one table i want to store the information of user (registration form), and in other table i want to store the result of the quiz of that particular user.
Now problem is that while storing the databse a error is coming " Duplicate Key error"... plz help me to remove this error
Is This A Good Question/Topic? 0
  • +

Replies To: Duplicate kye problem

#2 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 678
  • Joined: 26-May 08

Re: Duplicate kye problem

Posted 18 June 2008 - 09:21 AM

[rules][/rules]

well since you didn't post your code. I'm guessing that you are saving a record that has a primary key that is already in use. Maybe its not an auto generating key.
Was This Post Helpful? 0
  • +
  • -

#3 kaps  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 31-May 08

Re: Duplicate kye problem

Posted 18 June 2008 - 11:01 AM

hello frnds,

actually im using two form ..one for registration and other for quiz..
im also using two insert for each form page..insert.php and insert1.php
im posting both scripts
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("testquiz", $con);
  $sql="INSERT INTO table1 (username, password, add_ress, ph_one)
VALUES
('$_POST[username]','$_POST[pass]','$_POST[add_ress]','$_POST[ph_one]')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "your registered";
mysql_close($con)
?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="quiz.php">click here to play quiz
	  </a>
</p>



now second page insert1.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("testquiz", $con);
  $sql="INSERT INTO table2 (q1, q2)
VALUES
('$_POST[question1]','$_POST[question2]')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Your quiz is submitted";mysql_close($con)
?>





now pl help me..why deuplicate key error comes
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1