Stop Concatenate when submitted twice

I know this is probably something incredibly easy but I for some reason am having a brain fart…

If I submit data to a table, for example, I submit 1234. The data saves to the table as 1234. If I go back to the same form and submit, say, abcd, the data then becomes 1234abcd. What’s a simple way to remove the old data (1234) and replace it with the new data (abcd)?

I’ve been baking my noodle on this for a couple hours now. It’s also been about 3 years since I’ve programmed in PHP/MySQL too though.

Code?

[code]<?php
$con = mysql_connect(“server”,“user”,“password”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

mysql_select_db(“db”, $con);

$sql=“INSERT INTO tablename (P2M1, P2M2, P2M3, P2M4, P2M5, P2PM1, P2PM2, P2PM3, P2PM4, P2PM5, P2A, P2P, P3M1, P3M2, P3M3, P3M4, P3M5, P3PM1, P3PM2, P3PM3, P3PM4, P3PM5, P3A, P3P, P5M1, P5M2, P5M3, P5M4, P5M5, P5PM1, P5PM2, P5PM3, P5PM4, P5PM5, P5A, P5P, P6M1, P6M2, P6M3, P6M4, P6M5, P6PM1, P6PM2, P6PM3, P6PM4, P6PM5, P6A, P6P, P2AVG, P3AVG, P5AVG, P6AVG, E2WF, E1WF)
VALUES
(’$_POST[P2M1]’,’$_POST[P2M2]’,’$_POST[P2M3]’,’$_POST[P2M4]’,’$_POST[P2M5]’,’$_POST[P2PM1]’,’$_POST[P2PM2]’,’$_POST[P2PM3]’,’$_POST[P2PM4]’,’$_POST[P2PM5]’,’$_POST[P2A]’,’$_POST[P2P]’,’$_POST[P3M1]’,’$_POST[P3M2]’,’$_POST[P3M3]’,’$_POST[P3M4]’,’$_POST[P3M5]’,’$_POST[P3PM1]’,’$_POST[P3PM2]’,’$_POST[P3PM3]’,’$_POST[P3PM4]’,’$_POST[P3PM5]’,’$_POST[P3A]’,’$_POST[P3P]’,’$_POST[P5M1]’,’$_POST[P5M2]’,’$_POST[P5M3]’,’$_POST[P5M4]’,’$_POST[P5M5]’,’$_POST[P5PM1]’,’$_POST[P5PM2]’,’$_POST[P5PM3]’,’$_POST[P5PM4]’,’$_POST[P5PM5]’,’$_POST[P5A]’,’$_POST[P5P]’,’$_POST[P6M1]’,’$_POST[P6M2]’,’$_POST[P6M3]’,’$_POST[P6M4]’,’$_POST[P6M5]’,’$_POST[P6PM1]’,’$_POST[P6PM2]’,’$_POST[P6PM3]’,’$_POST[P6PM4]’,’$_POST[P6PM5]’,’$_POST[P6A]’,’$_POST[P6P]’,’$_POST[P2AVG]’,’$_POST[P3AVG]’,’$_POST[P5AVG]’,’$_POST[P6AVG]’,’$_POST[E2WF]’,’$_POST[E1WF]’)”;

if (!mysql_query($sql,$con))
{
die('Errors: ’ . mysql_error());
}

mysql_close($con)
?> [/code]

It’s ugly but it works until I feel like cleaning it up. If I submit it, it writes correctly. If I submit data again, whether on accident or say I push F5 to refresh the page, it concatenates the data… Doesn’t overwrite it…

Well refreshing a page automatically resends any form data but I don’t get why that would concatete it. Also INSERT doesn’t over write anyway, look into UPDATE for mysql syntax.

Sponsor our Newsletter | Privacy Policy | Terms of Service