Hi, The contents of a FORM are received from a previous page and stored in the variable $EDIT. I am then sending the contents of $EDIT to a MySQL database: It works just fine: the contents of $EDIT are sent to the database. However... and this is what's driving me nuts; it sends TWO entries, a first and a second entry - the first entry, including the contents of $EDIT and then a second and unwanted entry with no text input, just a blank area where the text should be. I get two duplicate records, but one has text and the other has just a blank space. How do I stop it from sending two entries? Any idea why it's send a second entry with nothing in it, i.e. $EDIT with no data? Is there any way I can limit the entry to just 1? Am I doing something fundamentally wrong?? Thanks in advance for your tips and ideas. It's appreciated.
Does your form reload the same page ? You could consider adding an if empty statement: If the variable $name for example has no data, the query wont run <?php require ('db_connect.inc.php'); if (empty($Name)) { //do nothing }else{ $result = mysql_query("INSERT INTO TrackReviews (ID, Name, Review, FixedID, ModifiedDate) VALUES ('NULL', '$Name', '$EDIT', '$FixedIDvalue', NOW())"); } ?> PHP:
I don't see a problem with your query however remove the quotes from the NULL (or better don't mention the ID). Chances are theirs a problem with your validation earlier on.
It sounds like you're calling the query code twice. Is it in a looping construct like a foreach or do while? Do the other vars have any value? Is $EDIT the only one empty? That may help you track down where it's getting repeated.