The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when updating table with 0
#1
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
}
  Reply


Messages In This Thread
Error when updating table with 0 - by gaiusjaugustus - 09-06-2017, 03:52 AM
Error when updating table with 0 - by Brandin - 09-06-2017, 09:23 AM
Error when updating table with 0 - by mudmin - 09-06-2017, 01:55 PM
Error when updating table with 0 - by mudmin - 09-06-2017, 02:50 PM
Error when updating table with 0 - by mudmin - 09-06-2017, 03:46 PM
Error when updating table with 0 - by faguss - 09-06-2017, 08:31 PM

Forum Jump:


Users browsing this thread: 6 Guest(s)