The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Error when updating table with 0 - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Error when updating table with 0 (/showthread.php?tid=722) |
Error when updating table with 0 - gaiusjaugustus - 09-06-2017 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 } Error when updating table with 0 - Brandin - 09-06-2017 I've had this happen before to, and dropped my "required" value and it fixed it. Definitely something in particular to the validation class. @Mudmin @karsen - any thoughts? Error when updating table with 0 - mudmin - 09-06-2017 Hmm. I've never come across this before. Are you getting an error about the field being required? Looking at users/classes/Valdidate.php I see that line 46 says Code: if ($rule==='required' && $length==0) { I'm wondering if that length needs to be changed to === Can you see if that fixes your problem? Sorry for the delay. Power is out here in my part of Alaska so communications are minimal. Error when updating table with 0 - gaiusjaugustus - 09-06-2017 I have no qualms with removing the required field if need be, but of course would love to find the issue. Thanks so much for the responses. My users/classes/Validate.php doesn't have that line at 46. But I do have at line 38: Code: if ($rule === 'required' && empty($value)) Code: $length Code: $length===0 I just redownloaded 4.2.10 from the main site to be sure I have the right version, and yes, line 38 is what is in my current Validate.php Good luck with the power outages and thanks again for the timely response. -Gaius Error when updating table with 0 - mudmin - 09-06-2017 Oooh. I forgot. I was looking at the new Validate.php from 4.3 alpha. What about the latest Validate.php? https://pastebin.com/yhbEyKYh If that doesn't work...what about the line 46 change on the one I just sent you? We've done extensive reworking of the validate class and may have already fixed the issue. Error when updating table with 0 - gaiusjaugustus - 09-06-2017 I replaced my Validate.php with the US 4.3 version of Validate.php given at https://pastebin.com/yhbEyKYh and the problem is now fixed. The line 46 change was not necessary. Thanks so much! I'm almost ready for my project to go live. Thanks again for all the help and hard work. Error when updating table with 0 - mudmin - 09-06-2017 Awesome! Glad it worked! Error when updating table with 0 - faguss - 09-06-2017 Function Code: empty Code: strlen >I’m wondering if that length needs to be changed to === No. Actually why Code: $rule===required |