php - PDO bindValue works for other inputs, why not this one? -


I am creating a form where users can update the features of books. Is a dynamic formatted HTML form where users can enter new values ​​for things like "title", "author", and "description", which looks something like this:

  resonance "& lt; form id = changerform name = changerform action = updates mm.fip method = post & gt;"; Echo "& lt; span id = titlebox & gt; Title: & lt; input class = attributefield style = 'border: none' type = text size = 100 id = title value = ''. $ Item ['title']. ' / 'Gt; ; Change it? & Lt; / Span & gt; & Lt; Br> "; Echo" & lt; Span id = authorbox & gt; Author: & lt; Input class = attributefield style = 'border: none' type = text id = author value = ''. $ Item ['author'] '' / & Gt; replace it ? From & lt; / Span & gt; & Lt; Br> "; Echo" & lt; Span id = description & gt; Details: & lt; Textarea class = attributefield style = 'border: none' rows = 9 cols = 100 names = description id = description & gt; $ [Item] '' ['description']. & Lt; / Text field & gt; & Lt; / Span & gt; "; Echo" & lt; Input type = 'hidden' id = 'bookidfield' name = 'bookidfield' value = '". $ ToChange."' / / & Gt; ";  

This form is controlled by some PHP Is that which looks like this:

  while ($ nowfield = current ($ _ POST)) {$ col = key ($ _POST); switch ($ cold) {case 'title' : $ Qstring = 'Update Headbooks SET title = Item idI: Booked;'; breakage; case 'author': $ qstring = 'Update menbooks ST author =: slug where item IDID: booked;'; breakdown; 'Description': $ qstring = "Update Menbooks SE T details =: flat where item id id: booked; "break; default:" invalid input "echo; breakdown;} // and switch $ upquery = $ safelink- & gt; ready ($ qstring); $ Upquery- & gt; ; Bind Value (': Slug', $ Now Field, PDO :: Param_st); $ Upquery- & gt; Bind Value (': Booked', $ _POST ['Bookfield'], PDO :: Paramatti); $ Upquery- & Gt; Execute (); Next ($ _ Post);} // End  

I have organized it as a switch statement, because the form has code that only Those fields The passes, which were replaced in the post (with the exception of Bukidfild) input, which with a unique key for each item.) Switch, run only essential question.

'Title' and 'Author' fields work fine; They update new values ​​without releasing 'details' area, however, always updates on the value of 'booked field'. I can fix this if I move in and manually change the 'book' parameter to the book's ID.

If I find var_dump (_ $ POST) to come through the right key values, such as:

  array (4) {["Title"] = & gt; String (22) "Gross buglers and such" ["Author"] = & gt; String (14) "Fanny Panties" ["Details"] = & gt; String (55) "This is the value that I want to change details !!" ["Bookidfield"] = & gt; But in my SQL table, it will change the title of the 184 book as the author of "Gross Boggers and Essays" and "Frankie Panties", but it will change the description to "184" I have to do something to use Bind Value (), right? Or what does it have to do with my loop? How is that name?  

Thank you Stakevaroff Flo, you guys are great.

Your problem is, when $ call is different for the title, author or description, in other words , When the switch executes the default case, then you are executing the previous query with $ nowfield = 184. The query should not be executed.

When the switch executes the default case, you will have to "jump" in the next value, except for query execution.

  default: resonance "invalid input"; Next ($ _post); Continued 2; break;  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -