+ Reply to Thread
Results 1 to 4 of 4

Thread: need help with mysql

  1. #1
    NielsJanssen is offline x10Hosting Member NielsJanssen is an unknown quantity at this point
    Join Date
    Jun 2005
    Location
    Europe, The Netherlands
    Posts
    74

    need help with mysql

    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 Code:
    <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 by NielsJanssen; 08-05-2005 at 03:43 PM.



  2. #2
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: need help with mysql

    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 by Bryon; 08-05-2005 at 11:47 PM.

  3. #3
    NielsJanssen is offline x10Hosting Member NielsJanssen is an unknown quantity at this point
    Join Date
    Jun 2005
    Location
    Europe, The Netherlands
    Posts
    74

    Re: need help with mysql

    thanx i figured it out



  4. #4
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: need help with mysql

    Your welcome. If you ever need any more help.. just ask.

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. MySQL server address HELP :S
    By rinnerz.com in forum Free Hosting
    Replies: 5
    Last Post: 07-09-2006, 10:25 AM
  3. in here MySQL version????
    By winUSD in forum Free Hosting
    Replies: 4
    Last Post: 05-09-2006, 08:44 AM
  4. Have a problem with my forum
    By tikloos in forum Scripts & 3rd Party Apps
    Replies: 43
    Last Post: 01-19-2006, 01:14 AM
  5. MySQL problem
    By pensoftware in forum Free Hosting
    Replies: 3
    Last Post: 10-30-2005, 12:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers