[eluser]Bramme[/eluser]
See my last reply please. This is very very weird.
Okay, I'm encountering one of the weirdest bugs I've ever had.
I have a form on a website I made for submitting tutorials. There's a title and short description field, an avatar image file field, a set of radiobuttons for selecting a rank and checkboxes for categories. And a larger textarea where the actual content from the tutorial comes.
When I just put "test" in that last textarea everything gets submitted fine, no problems. However when I enter a large piece of text in the textarea and hit submit, I get my 404 page. The url doesn't change and I have NO idea where the error could be thrown.
I'll try to include some relevant code.
The form:
Code:
<form action="<?php echo base_url(); ?>admin/tutorial/new_tutorial" method="post" enctype="multipart/form-data">
<div class="left">
<p>
<label for="title">title<br />
<input type="text" name="title" id="title" value="<?=$this->validation->title?>" />
</label>
</p>
<p>
<label for="content">Description<br />
<textarea name="content" id="content" style="height: 50px"><?=$this->validation->content?></textarea>
</label>
</p>
<p>
<label for="contentHTML">contentHTML<br />
<textarea name="contentHTML" id="contentHTML" style="height: 500px"><?=$this->validation->contentHTML?></textarea>
</label>
</p>
</div>
<div class="right">
<p class="lower">
Thumbnail<br />
If no thumbnail is selected, the cms will revert to the standard M<br />
<input type="file" name="imageLoc" id="imageLoc" />
</p>
<p class="lower">
Select the rank for this tutorial: <br /><br />
<? foreach($ranks->result_array() as $rank): ?>
<label for="rank-<?=$rank['rankID']?>"><input type="radio" name="rankID" value="<?=$rank['rankID']?>" id="rank-<?=$rank['rankID']?>" <?php echo $this->validation->set_radio('rank', $rank['rankID']); ?>/> <?=$rank['name']?></label><br />
<? endforeach; ?>
</p>
<p class="lower">
Select the categories for this tutorial: <br /><br />
<? foreach($cats->result_array() as $cat): ?>
<label for="cat-<?=$cat['catID']?>"><input type="checkbox" name="categories[]" value="<?=$cat['catID']?>" id="cat-<?=$cat['catID']?>" <?php echo $this->validation->set_checkbox_array($cat['catID'], $this->input->post('categories')); ?>/> <?=$cat['name']?></label><br />
<? endforeach; ?>
</p>
</div>
<p style="clear: both">
<input type="submit" name="submNewTutorial" value="Submit" />
</p>
</form>
The controller:
Code:
$rules['title'] = 'trim|required|xss_clean';
$rules['content'] = 'trim|required';
$rules['contentHTML'] = 'required';
$rules['rankID'] = 'required';
$rules['categories[]'] = 'callback_required_checkbox';
$this->validation->set_rules($rules);
$fields['title'] = 'tutorial title';
$fields['content'] = 'description';
$fields['contentHTML'] = 'actual content';
$fields['rankID'] = 'rank radiobuttions';
$fields['categories[]'] = 'categories';
$this->validation->set_fields($fields);
$this->validation->set_error_delimiters('<li>', '</li>');
if ($this->validation->run() == TRUE)
{
if ( ! $this->backend->add_tutorial())
{
send_notice('error', 'Something went wrong with the query', 'self');
}
else
{
send_notice('success', 'Tutorial successfully added', 'self');
}
} else {
if( ! empty($this->validation->error_string)) {
send_notice('validation_error', $this->validation->error_string);
}
}
The model
Code:
function add_tutorial($edit_id = NULL) {
// if true = no errors, if false = errors
$error = TRUE;
$insert['title'] = $this->input->post('title');
$insert['content'] = $this->input->post('content');
$insert['contentHTML'] = $this->input->post('contentHTML');
$insert['rankID'] = $this->input->post('rankID');
//datetime pattern example: 2006-01-03 13:24:10
$insert['datetime'] = unix_to_human(time(), FALSE, 'eu');
//code to process thumbnails
// depending on wether editting or adding a tut
if(isset($edit_id)) {
$this->db->where('tutID', $edit_id);
if( ! $this->db->update('tutorial', $insert)) {
$error = FALSE;
}
} else {
if( ! $this->db->insert('tutorial', $insert)) {
$error = FALSE;
}
}
// code that handles the categories
}
Could this have anything to do with a memory problem? Too much characters in the textarea?[/size]