Question:
Why MySQL (using PHP's "mysql_query()" function) INSERT INTO statements messed up?
P.S.P.
2008-12-28 23:10:43 UTC
I just started MySQL, and I'm currently in the basics, the real basics, where I only know how to connect to my own localhost database, create a database, create tables, and insert values manually to database tables. However, when I tried doing some HTML forms using PHP scripts to add new rows on a database table, the information from the form gets inserted more than once, sometimes even 5 times, exactly, and only in one submission... Does anyone know SQL here? Using the SQL's "INSERT INTO" statements manually, as in directly in the PHP script, without using HTML forms to collect manually-submitted user info, I was able to create only one database entry to a table... I've set a primary key, but it's only for the ID of one table, and if I set more than one primary key PHP creates an error saying multiple primary keys are not allowed... Anyway let me sum it up for those who understands PHP and MySQL very well:

I need help making a script that will use SQL's "INSERT INTO (...) VALUES (...) " statements, which the value is collected from a HTML form and submitted once by a user... and only ends up inserting 1 entry in a database table, and not inserting 2-6 entries at once... Thanks!
Four answers:
just "JR"
2008-12-29 01:19:09 UTC
You most likely have a "logic" mistake in your submitting code.

Post it here.
?
2016-10-19 07:01:09 UTC
completely incorrect thank you to try this. Use ONE variety. enable it call itself. Run a verify that the post button has been pressed, if it has no longer the internet site maintains and a lot the variety, set the values to be the post variables from the variety, which of course would be empty. If the post has been pressed run the validation code to be sure all fields are crammed in, additionally that the digital mail handle is formatted as an digital mail handle (there are serious protection matters whether it is not wisely formatted) and that issues like password confirmation suits password. Create an blunders record for something that fails so which you will demonstrate it on the variety. If this is actual run the insert. If no longer enable it proceed to the variety returned, this time it rather is going to of course fill interior the post variables and enable the consumer re-enter required fields. If the validation passes you could then re-direct to everywhere you decide on.
Abhishek K
2008-12-29 03:35:12 UTC
most probably you have messed up your quotes, check them properly
anonymous
2008-12-29 00:51:57 UTC
try this

http://www.w3schools.com/SQL/sql_insert.asp


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...