Jump to content

Undefined index: min in /phpvalidation.php on line 100


ephbaum

Recommended Posts

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 100

case '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.
Link to comment
Share on other sites

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 53

Can'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 by requinix
Link to comment
Share on other sites

 

 

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.

Link to comment
Share on other sites

$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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.