Why won’t my form data insert properly into my MySQL database? Here’s the most common reasons why:
Get the updated source code for this video here.
- Not connecting to MySQL properly
- Not matching form fields to database columns properly
Issues Connecting to MySQL
When you run into connection issues, you’ll usually see an error that will say there was a problem connecting to the database.
More often than not, it’s simply a typo in your database name, username, or password.
Make sure to triple-check that information. Also, keep in mind if you’re using source code I’ve provide you’ll need to change those values to whatever they are for YOUR database.
Issues Matching Form Fields to Database Columns
Almost always, this is caused by a mis-match between your form field names and your database column names.
In your SQL statement, you do the matching directly. Here’s a quick example:
INSERT INTO table_name (database_column_1, database_column_2) VALUES (form_field_1, form_field_2)
So you need to match the form field value to the database column.
I go much more in-depth with this in the video, so be sure to watch it if you’re having this problem.
If you enjoyed this tutorial and want to keep learning PHP, you can start taking my full course for free on my free tutorial site here: https://johnsfreetuts.com/php/
This Post Has 9 Comments
Nice!
by Carros
Very good information. Thanks…
Word!
I like the way you explain. very clearly thank you
No problem!
Great, Thanks for sharing.
Hey,
Great, thanks for sharing us. really it’s very useful.
great article, thanks for sharing us.
great article, thanks for sharing us.