Page 1 of 1

php script keeps submitting 2 rows into database

Posted: Wed Jul 19, 2006 8:15 pm
by blobman
I am having trouble with mysql and php.

The mysql is fine, when I insert a row in php my admin it works.

In my php script, I made a script that works fine, but I also have a script that just runs ONCE. For some reason the query is being inputted twice or something.

I've tried everything. Has anyone heard of a problem like this before, and do any solutions come to mind?

Thanks
Cameron

Posted: Wed Jul 19, 2006 8:20 pm
by Burrito
need to see some code we do.

Posted: Wed Jul 19, 2006 8:20 pm
by blobman
OK!!! I FIGURED IT OUT!!! BUT WHY!!!!!!!!!!!!!!!!!!!!!!!!!!

Heres the thing. I had a form, but I also had a new button right next to it.

I used a form button as my html button.
<input type="button" name="submitButtonName" />

I put a link around that button (and put a lable in it) for my button. For some reason, and it just hit me now, that button was submitting everything twice. My delete script was going wacko too. Now it works fine.

So does anyone know why this happened?

Thanks
Cameorn

Posted: Thu Jul 20, 2006 3:02 am
by RobertGonzalez
I would venture to guess that you may have had two field names that were identical and that that particular field name was being used as an IF check. I am not sure this would do it, but at this time of morning it is my best guess.

Posted: Thu Jul 20, 2006 2:55 pm
by blobman
The buttons werent in a form, they were just links.

They linked to a page new.php and delete.php that just getnerated new entries or moved old ones to the trash.

but it seems when i turned that button into text, the double submit didnt happen anymore.

Heres the weird thing
The form button some times ran the script twice, but also, sometimes it ran it once.

But for anyone coding php scripts, never make your button a form button!!