Database Insert Problem

Ok i wrote an insert script and a form page for a URL database. The first time i inserted something it worked fine, the second time i got the “system error” else statement in my code.
My database is set up like this:

id, title, description, url, type, tutorial

Here is the insert script:


<? 
require_once '../mysql_connect.php'; 

if(isset($_POST['Submit'])){

    $t = $_POST['title'];
    $d = $_POST['description'];
	$u = $_POST['url'];
	$type = $_POST['type'];
	$tutorial = $_POST['tutorial'];
     
	$query = "INSERT INTO urls (title, description, url, type, tutorial) VALUES ('$t', '$d', '$u', '$type', '$tutorial')";
	
    $result = mysql_query($query); 
    $n = mysql_affected_rows(); 
    if ($n > 0){ 
        echo 'Event successfully entered!!!'; 
    }else{ 
        echo  'System Error'; 
    } 
    mysql_close();  
	}
	
	else {
	echo 'Form Error';
	}     

   exit(); 

?>

here is my form page:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Christian Design</title>
<link href="../style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
}
-->
</style></head>

<body>
<center>
  <table width="780"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td width="131" class=".style1" valign="top">  <div align="left">       </div>
      <div align="left"></div></td>
      <td width="527" valign="top" ><form name="form1" method="post" action="url_insert.php">
        <table width="100%"  border="0" cellspacing="0" cellpadding="4">
          <tr class="style1">
            <td colspan="2"><p align="center"><strong>URL Data Submission Page </strong></p>
              <p>This page is for submitting url data to the url database. It does not upload the actual file, its just for inputting the information for the site search and other data. </p></td>
            </tr>
          <tr class="style1">
            <td width="28%">Title:</td>
            <td width="72%"><input name="title" type="text" id="title" size="25"></td>
          </tr>
          <tr class="style1">
            <td>Description:</td>
            <td><textarea name="description" cols="50" rows="4" id="description"></textarea></td>
          </tr>
          <tr class="style1">
            <td>Url:</td>
            <td><input name="url" type="text" id="url" size="50"></td>
          </tr>
          <tr class="style1">
            <td>Type of Page:</td>
            <td><input name="type" type="text" id="type" size="25"></td>
          </tr>
          <tr class="style1">
            <td>Tutorial Type: </td>
            <td><input name="tutorial" type="text" id="tutorial" size="25"></td>
          </tr>
          <tr class="style1">
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit" value="Submit">
              <input type="reset" name="Reset" value="Reset"></td>
          </tr>
        </table>
        <p class="style1">&nbsp;</p>
      </form></td>
      <td width="122" valign="top"><div align="left"></div></td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>
</center>
</body>
</html>

I havent looked thoroughly through your code, but try this to see exactly what the error is. Replace the INSERT query with this:

$query = "INSERT INTO urls (title, description, url, type, tutorial) VALUES ('$t', '$d', '$u', '$type', '$tutorial')"; 
	 
	if (!$result = mysql_query($query)) die (sql_error()); 

alright ill check it out;)

ok i got this:

Duplicate entry ‘blah’ for key 2

looks like its not incrementing correctly, hmmm i think i might know the answer, i deleted the first 2 records so it might be starting from the beginning and trying to increment back up.

edit:

I might have fixed it, it was something to do with a secondary key that i assigned to the url field.