Mysql not updating before next form

You can extend this example and make it more interactive by adding validations to the user inputs before inserting it to the database tables.Please check out the tutorial on PHP form validation to learn more about sanitizing and validating user inputs using PHP.In this tutorial you will learn how to execute SQL query to insert records in a table.Let's make a SQL query using the INSERT INTO statement with appropriate values, after that we will execute this SQL query through passing it to the mysqli_query() function to insert data in table.This didn't initially work for me because my ID was not unique.Also note that you can use VALUES (name) to reference to the value you attempt to insert e.g.

Now that you've understood how to create database and tables in My SQL.

INSERT INTO table (id, name, age) VALUES(1, "A", 19) ON DUPLICATE KEY UPDATE name=VALUES(name) , age=VALUES(age)The other problem with REPLACE INTO is that you must specify values for ALL fields...otherwise fields will get lost or replaced with default values.

To see this in action, try adding another record using the following statement: When a user clicks the submit button of the add record HTML form, in the example above, the form data is sent to 'insert.php' file.

The 'insert.php' file connects to the My SQL database server, retrieves forms fields using the PHP This is very basic example of inserting the form data in a My SQL database table.

I know all of you allude to this, but I want to be explicit for others.

If the ID you insert is NOT the PRIMARY KEY or UNIQUE, then this will not work.


  1. Pingback:

  2. eric   •  

    If you have any special request share it with me and lets do it... Hot and sensual striptease, role plays, squirt,many toys and lingerie..

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>