Welcome Guest, Not a member yet? Register   Sign In
bug when setting $_POST array field to null?
#10

(10-28-2015, 10:53 AM)redjersey Wrote: what I meant is, when manually setting $_POST['sold_for_price'][1] to null, it won't reflect changes on $this->input->post('sold_for_price')[1] (empty string) (forget about the loop if it confuses you).

He wasn't confused, the code you posted was wrong. This is why people like to see code which demonstrates the issue before they investigate further. If you are actually using the code you posted, you should be getting errors beyond what you are reporting. The difference between i and $i is a minor typo, but it's significant.

It should also be noted that structuring your loop in certain ways might cause a problem like this.

Unless you're using PHP 5.3 or less, the difference between $this->input->post('sold_for_price')[1] and $_POST['sold_for_price'][1] when reading the value is essentially an isset() check, unless you have global XSS filtering enabled (in which case you may or may not receive other errors).

Finally, while I'm interested in determining what is going on here, I do feel the need to say that you would be better off not modifying the $_POST data in the first place. it would be better to create a variable (or set of variables) to hold your filtered $_POST data and pass the filtered data instead of the $_POST data. I do this to make sure I'm only passing the fields I actually use in my model, make sure each field is set to reasonable defaults for the data type if nothing was submitted (and the field isn't required), etc.
Reply


Messages In This Thread
RE: bug when setting $_POST array field to null? - by mwhitney - 10-28-2015, 12:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB