php - Inserting data with PDO. I have tried so many ways and failed -
I have just started learning PDOs I have connected to my database and working with me with my SQL database is. Now I am trying to get three pieces from a form and then put them in the table. I have been on this for a week and I fail in every edition. I do not get any error message yet when I check the table it remains empty
As I have other PDO proceedings, I believe this problem is in the following part of the code. The included button is named 'addGig'. This is the first time I have used the name of a button ... I do not trust this.
I have just edited this post to include my modified code. Too many rookies!
$ date = $ _POST ['date']; $ Place = $ _POST ['place']; $ Time = $ _POST ['time']; If ($ empty) & amp; empty ($ site) & amp; empty! ($ Time)) Try {{$ query = $ connect-> ("Gears initially (date, location, time) (: Date, location, time) "); $ Query-> Baidam Parm (': Date', $ date); $ Query-> Beyond Parm (': place', $ site); $ Query-> Beyond Parm (': time', $ time); $ Query-> Executed (); } Hold (PDOException $ e) {handle_sql_errors ($ query, $ e-> getMessage ()); }} }
This is my html form
& lt; Form & gt; & Lt; Label & gt; Date & lt; / Label & gt; & Lt; Br> & Lt; Input type = "article" name = "date" & gt; & Lt; Br> & Lt; Label & gt; Venue & lt; / Label & gt; & Lt; Br> & Lt; Input type = "article" name = "site" & gt; & Lt; Br> & Lt; Label & gt; Time & lt; / Label & gt; & Lt; Br> & Lt; Input type = "article" name = "time" & gt; & Lt; Br> & Lt; Br> & Lt; Button type = "submit" value = "adgag" name = "adgig" & gt; Add Junk & lt; / Button & gt; & Lt; / Form & gt;
Here are some issues (Now known to post your form code ).
One of which is, you & lt; Form & gt; , it is in conjunction with your $ _ POST variables.
So you have to post it to a specific method.
& lt; Form method = "post" & gt; Plus, without taking any action, default for yourself.
If you are using a different form than your SQL, then you have to specify it.
Ie:
Alternatively, you're using quotes for your column. Remove them or use ticks.
This is not the correct identifier according to your basic question
('date', 'place', 'time')
-
Comments
Post a Comment