ephbaum Posted March 7, 2015 Share Posted March 7, 2015 I"m getting two errors. I am not a programmer. Can usually grind it out the hard way but not getting anywhere with this one. Notice: Undefined index: min in /phpvalidation.php on line 100case 'string': $this->validateString($var, $opt['min'], $opt['max'], $opt['required']); <LINE 100 if(!array_key_exists($var, $this->errors)) { $this->sanitizeString($var); } Warning: Cannot modify header information - headers already sent by (output started at /phpvalidation.php:100) in /doeditprofile.php on line 53 $publicOrNot = true; if($_POST['publicProfile'] == "false") { $publicOrNot = false; } $dbhandle = new mysqli("localhost", "XXXXXX_website", "2dc57pdgHxtLWfAQ", "XXXXXX_archivemain") or die("Unable to connect to MySQL"); $updateStatement = $dbhandle->prepare("UPDATE users SET firstName=?, lastName=?, postcode=?, profileText=?") or die("errorUP"); $updateStatement->bind_param('ssss', $_POST['firstName'], $_POST['lastName'], $_POST['postcode'], $_POST['profileText']) or die("errorDO"); $result = $updateStatement->execute() or die("error 3"); header('location: profile.php'); <LINE 53 } I don't get how 'min' is undefined. Was getting a bunch of 'undefined''s but solved that with isset. I'm lost. Quote Link to comment Share on other sites More sharing options...
requinix Posted March 7, 2015 Share Posted March 7, 2015 (edited) Notice: Undefined index: min in /phpvalidation.php on line 100[edit] At some point there was a response in here... Something, something, array doesn't have a min in it. [/edit] Warning: Cannot modify header information - headers already sent by (output started at /phpvalidation.php:100) in /doeditprofile.php on line 53Can't use header() if there's been output. In this case the output came from that first error message (notice where it said the output started) so when you fix that then this one will go away too. Edited March 7, 2015 by requinix Quote Link to comment Share on other sites More sharing options...
boompa Posted March 7, 2015 Share Posted March 7, 2015 I don't get how 'min' is undefined. You should use var_dump on the contents of $opt, which should demonstrate that at least the "min" key is not set. Without knowing how that array is populated, we can't tell you more than that PHP is not lying to you about the "min" key being unset. Quote Link to comment Share on other sites More sharing options...
ephbaum Posted March 7, 2015 Author Share Posted March 7, 2015 $rules_array = array( 'firstName'=>array('type'=>'string', 'required'=>true, 'min'=>2, 'max'=>30), 'lastName'=>array('type'=>'string', 'required'=>true, 'min'=>2, 'max'=>30), 'postcode'=>array('type'=>'string', 'required'=>true, 'min'=>5, 'max'=>10), 'profileText'=>array('type'=>'string', 'required'=>true, 'min'=>5, 'max'=>350) ); The last line was missing min and was written like this: 'profileText'=>array('type'=>'string', 'required'=>false, 'max'=>350) I changed it to true and added the min back in. The profile text isn't required so how would I write it to not be required? It cleared those 2 errors, now I'm getting error2. Now off to see if I can figure these out. Thanks a ton for your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.