Need help with error(s)

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. I do know about the php button above. Didn’t think it was appropriate for
this since it’s just a part of the pages.

Notice: Undefined index: min in /phpvalidation.php on line 100
[php]
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
}
[/php]
I don’t get how ‘min’ is undefined. Was getting a bunch of ‘undefined’'s but solved that with isset.

I’m lost.

The php button here just insert a php code block, makes the code more readable so it’s suggested to use it.

Where do you set $opt[‘min’]?

Regarding the header information it’s usually when you’re using multiple files (with include or require) and you output data without knowing it

[php]<?php

// some php code

?>
[/php]

Notice the empty line at the end? That will be interpreted as output and will potentially break your script(s) with the warning you have. Which is one reason to not close php blocks if you don’t have to.

As mentioned, I’m not a programmer but I’ll certainly try to keep up and learn. Still struggling with a lot
of the terminology.

If believe this is what you’re talking about.


public function addRule($varname, $type, $required=false, $min=0, $max=0, $trim=false)
    {
        $this->validation_rules[$varname] = array('type'=>$type, 'required'=>$required, 'min'=>$min, 'max'=>$max, 'trim'=>$trim);
        /*** allow chaining ***/
        return $this;
    }

I’ve looked at the related files to see if there’s an empty line and not seeing one. The phpvalidation page opens and closes, top & bottom correctly as does doeditprofile.php. editprofile.php opens and closes at the top and the w3 line is the next one.

Got it. :stuck_out_tongue:

It was missing a ‘min’ on the last line of the $rules_array

‘profileText’=>array(‘type’=>‘string’, ‘required’=>false, ‘max’=>350)
‘profileText’=>array(‘type’=>‘string’, ‘required’=>true, ‘min’=>5, ‘max’=>350));

I changed it to ‘true’ to get it to run but it’s not a required field so how do I set it
to not required?

Just remove the ‘required’=>true section all together or ) at the end of string or should
I have set it to false and ) there?

Sponsor our Newsletter | Privacy Policy | Terms of Service