Welcome Guest, Not a member yet? Register   Sign In
Problem with this input post (SOLVED)
#1

[eluser]tim1965[/eluser]
Hi

I have a strange problem. I have an input form that was working perfectly, but is now broke.
I am getting an insert error for field "town" saying the value has not been populated. However the $_post array is being populated correctly, however $this->input->post is applying a NULL value instead of the POST value.
Insert error message
Quote:
Column 'town' cannot be null
Quote:
Relevant parts of the code
Controller
$this->form_validation->set_rules('Town', 'Town', 'required|max_length[50]|alpha_dash_space');
View
<p>
<span class="cluetip" title="Title Field - This is a Mandatory Field. Please select your Title from the drop down list."><img src="&lt;?php echo base_url().'system/static/images/info.gif' ?&gt;" width="18" height="15" /></span>
<label for="Town" class="left">Select Town *</label>
<select name="Town" class="combo" id="Town" >[removed]sixLevel.printOptions("Town")[removed]</select>
<span class="phperror">&lt;?php echo form_error('Town'); ?&gt;</span>
</p>
Note there is some javascript populstion going on here, this is working correctly because i can see the value for this field correctly in the $_post array (excerpt below).
Quote:
array(53) { ["Region"]=> string(6) "Europe" ["Country"]=> string(5) "Spain" ["Province"]=> string(9) "Andalucia" ["Town"]=> string(5) "Nerja" ["locationother"]=> string(0) ""
Quote:
Model
$t = array (
$property_id'=>$prop['prop_id'][0],
'region'=>$this->input->post('Region'),
'country'=>$this->input->post('Country'),
'province'=>$this->input->post('Province'),
'town'=>$this->input->post('Town'),
'location_other'=>$this->input->post('locationother'),
'property_name'=>$this->input->post('propertyname'),
'property_highlights'=>$this->input->post('propertyhighlights'),
);
$this->db->insert('temp_property_details',$t);
The form is very large so i have only posted parts relevant to the town field.
When i dump the insert array $t i am getting
Quote:
VALUES ('1', 'Europe', 'Spain', 'Andalucia', NULL, '',
Quote:
a NULL value for the fifth field yet $_POST correctly has the value populated(see above).
I am very confused.
#2

[eluser]tim1965[/eluser]
Ok this obviously wasnt clear so i will try again.
I have a forn that has been working perfectly for the last 6 months. However i am now getting some problems with a specific field "town", this is a drop down select field that is part odf 4 fields. The dropdowns are populated by some javascript based on the previous selectioni.e. region, country, province, town. These are being populated correctly and are correctly populating the $_POST array (Please see previous post for exampes).
However when i run the insert for my model the value has been replaced with a "NULL" value and the insert fails. All the model is doing is grabbing the value of the
Quote:
$this->input->post('Town'),
Quote:
to build an array for insertion. So i seem to be losing the value somewhere between $_POST and $this->input->post.
I am not sure why this should be happening and it only happens on this field.
So if anyone has any ideas why this is haooening or how i can debug it further it would be very helpful.
If i amend the model to grab the $_POST value directly rather than using $this->input->post
, i get the same error.
#3

[eluser]tim1965[/eluser]
Solved

My fault. The form is very large and i was using the same variable name twice by mistake. Something to watch out for if you get a problem like this




Theme © iAndrew 2016 - Forum software by © MyBB