php script keeps submitting 2 rows into database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blobman
Forum Newbie
Posts: 9
Joined: Wed Nov 02, 2005 10:52 pm

php script keeps submitting 2 rows into database

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

need to see some code we do.
blobman
Forum Newbie
Posts: 9
Joined: Wed Nov 02, 2005 10:52 pm

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
blobman
Forum Newbie
Posts: 9
Joined: Wed Nov 02, 2005 10:52 pm

Post 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!!
Post Reply