Jump to content

inserts multiple rows into MySql


mrblack

Recommended Posts

Hi,

I am facing a vierd problem.

I do a insert with the data from a form. It gets updated fine into the database. Then i go to some other page and come back to the first page and i find that there are multiple entries of the previous data and the number is not fixed, it chages each time.

I have tried changing the auto increment and manually updating the serial number, still i see the same issue.

Any suggestions would be appretiated.

Thanks in advace.

Ducane.
Link to comment
Share on other sites

[!--quoteo(post=350257:date=Feb 28 2006, 11:27 AM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Feb 28 2006, 11:27 AM) [snapback]350257[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Are you using your back button? Some browsers repost form data without warning you.

Without seeing some code I'm afraid I can't be any more help than that.
[/quote]

$db = mysql_connect("localhost", "root", "root");
mysql_select_db("pts_extend", $db);

if (isset( $_REQUEST[add])) {
if(!($_REQUEST[add] == '')) {

$addValue = $_REQUEST[add];

$infoTypeResult = mysql_query("select itemtype from info_type", $db);

$maxValue = 0;

while ($infoRow = mysql_fetch_array($infoTypeResult)) {
if($infoRow[itemtype] > $maxValue) {

$maxValue = $infoRow[itemtype];

}
}

$maxValue++;

mysql_query("insert into info_type (itemtype,description) values ('$maxValue','$addValue')", $db);

mysql_query("commit");

}
}

if 'add' is set in request parameters, it will insert a row.
i know that if i do a refersh, that should add one more row. But i actually navigate to another page and by buttons and navigate back.
the number of rows may or may not be added and if added they are in random numbers - so that's really unexplainable.

I am not sure which one of apache, mySql or Php is doing that!

header("Location: nextpage.php");

good one.

my primary concern is inserting random addition.

This is how that looks, initially it did not show multiple entries!

Id Description
1 Deployment
2 BRD Ready
3 Tech Design
4 HLE
5 ewr ewr
6 wer t
7 ewr ewr
8 ewr ewr
9 ewr ewr
10 ewr ewr
11 ewr ewr
12 ewr ewr
13 ewr ewr
14 ewr ewr
15 ewr ewr
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.