09-06-2017, 03:52 AM
Hi,
I'm having a weird issue and hoping to get some help on it.
I'm using a form to update a MySQL table with something like the code below, where I (1) get a posted value (2) validate it, and (3) update the table. It works great, but there's an issue. Whenever 0 (zero) is sent, it throws an error, in this case saying that "Chapter number is required". I have no problems inserting a 0 into the MySQL table when I do it manually. I assume I've done something wrong in the validation. Any suggestions?
(Couldn't figure out how to insert multi-line code in the forums?)
$chapternum = Input::get('chapternum');
$fields=array('chapternum'=>$chapternum);
$validation->check($_POST, array(
'chapternum' => array(
'display' => 'Chapter Number',
'required' => true
)
));
if($validation->passed()){
$db->update('comic_chapters',$id,$fields);
$successes[] = "Chapter Number Updated";
}else{
?><div id="form-errors">
<?=$validation->display_errors();?></div>
<?php
}
I'm having a weird issue and hoping to get some help on it.
I'm using a form to update a MySQL table with something like the code below, where I (1) get a posted value (2) validate it, and (3) update the table. It works great, but there's an issue. Whenever 0 (zero) is sent, it throws an error, in this case saying that "Chapter number is required". I have no problems inserting a 0 into the MySQL table when I do it manually. I assume I've done something wrong in the validation. Any suggestions?
(Couldn't figure out how to insert multi-line code in the forums?)
$chapternum = Input::get('chapternum');
$fields=array('chapternum'=>$chapternum);
$validation->check($_POST, array(
'chapternum' => array(
'display' => 'Chapter Number',
'required' => true
)
));
if($validation->passed()){
$db->update('comic_chapters',$id,$fields);
$successes[] = "Chapter Number Updated";
}else{
?><div id="form-errors">
<?=$validation->display_errors();?></div>
<?php
}