need help with mysql

NielsJanssen

New Member
Messages
148
Reaction score
0
Points
0
i made a script that is supposed to add content to a mysql database. the problem is that i keep getting an error: Duplicate entry '' for key 1

could someone please tell me what i am doing wrong???

this is the script i use
PHP:
<html>
<head>
<title>MP3 UPLOAD SYSTEM
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.box {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	border: 1px solid #000000;
}
-->
</style>
</head>

<body>
<?
if(isset($_POST['upload'])){

		include 'library/config.php';
		include 'library/opendb.php';
		
		$query = "INSERT INTO tbl_Main (mainTitle, mainDate, mainContent ) ".
			 "VALUES ('$mainTitle', '$mainDate', '$mainContent')";

 	mysql_query($query) or die(mysql_error());	 			
		include 'library/closedb.php';
		echo 'The content is added';
		}
			
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
  <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
  <tr>
	<td>Titel:
	<td width="246">
  <tr>Upload date:">
  <tr>
	<td>Content:
	<td>
	  <td width="80" colspan="2" align="right">
	</tr>
  </table>
</form>
</body>
</html>
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Ok, that error is telling you this basically:

"You are trying to insert a new row that has the same "mainTitle" column, but it isn't aloud."

It isn't aloud because in the mysql database, that table's "mainTitle" column has "Unique Key" set on it.

Unique Key makes it so that no two rows in that database table can have the same exact value for that column.

The easist way to fix it is to make sure no two things you try to insert have the same value for "mainTitle". If you need more help, post here.

I'm not sure how well you know PHP + MySQL, so either from this, you know how to fix it, or you don't. If you don't, just post what you have tryed and all, and we/I will try to help you further.
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Your welcome. If you ever need any more help.. just ask.
 
Top