#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    65
    Rep Power
    15
    I have a simple insert code to add data from an HTML form to a mysql database.
    Here's what it looks like <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php
    mysql_connect("localhost","root");
    mysql_select_db("custproject");
    mysql_query("INSERT INTO customerproject(account_number,customer_name,contact,scheduled_work_date,date_work_completed,comment s,total_time_worked,staff_assigned) VALUES
    ('$account_number','$customer_name','$contact','$scheduled_work_date','$date_work_completed','$comme nts','$total_time_worked','$staff_assigned')");
    print "Done";

    ?>
    [/code]


    What am I doing wrong? Any suggestions?
    TIA,
    Ben
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    NY, NY,USA
    Posts
    18
    Rep Power
    0
    This code doesn't look so bad, but is that the whole page? You're saying that the php adds two rows to the table or that the data in each column is 2x what it is supposed to be?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    65
    Rep Power
    15
    That is the whole code except for <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><html> and <body>[/code]
    tags.
    It adds two rows to the table.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    6
    Rep Power
    0
    How's it going,

    The code looks fine.
    Are you sure you haven't accidentally clicked back or refresh to that page and resubmitted the data and redone the query?
    I did that once and managed to confuse myself.

    Later
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    65
    Rep Power
    15
    Nope. This happens everytime. I Click submit once, and it adds it twice, everytime.

    Everybody Stumped Yet?

    Ben
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    I'm Stumped, that is wierd.

    Maybe you could try making the customer name field UNIQUE so that the second one wont go in. That is, if you can't stop it adding two in the first place.

    Good luck
    Basil
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    65
    Rep Power
    15
    Thanks for the idea. It solved the problem of adding things twice... but I still dont' know why it was.

Similar Threads

  1. Replies: 0
    Last Post: February 11th, 2004, 07:48 AM
  2. Time wont insert into the database, HELP!
    By SE7EN in forum PHP Development
    Replies: 8
    Last Post: January 23rd, 2004, 05:35 PM
  3. Replies: 1
    Last Post: January 6th, 2004, 11:46 PM
  4. Zip code validation
    By krwyth in forum MySQL Help
    Replies: 2
    Last Post: January 5th, 2004, 01:29 PM
  5. insert files in folder into database by type
    By redzred in forum PHP Development
    Replies: 0
    Last Post: January 4th, 2004, 10:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo