storing results of a function - previous result overwritten with new result


Posted on 16th Feb 2014 07:03 pm by admin

I have created a function to validate input.

function validate_dimension($value,$name) {

global $errors;
$errors = array();

......validation actions here - this all works fine - if I get an error it is captured like this . . .

$errors[] = "Dimension value missing";

This is all fine and the $error is returned correctly.

So that I can keep the error, I save it as a Session variable

$_SESSION['errors'] = $errors;

HOWEVER the next time I run the function (with the next dimension to be checked) , $_SESSION['errors'] is overwritten and the first error is lost.

I have solved the problem by creating a new array - $all_errors - and adding $errors to $all_errors each time the function is run - but this seems clumsy - I do not need the function as I could just as easily wite a separate line of code for each dimension to be checked.

Can anyone suggest a better way of doing this?
Please?

No comments posted yet

Your Answer:

Login to answer
205 Like 31 Dislike
Previous forums Next forums
Other forums

utl_file open error
i have file in the unix path

Path /popdev01/pop/popdevb/tfi/

File name

Simple PHP/Java Help..
Hi,
I'm trying to build a little program to do with calculating postage. Unfortunately i haven't

SAP Project Module
I have seen in the SAP Project Module,plan cost and budget are not equal and even difference is sign

Comma seperated implode & modifying returned string.
I have a PHP post form that posts up to 4 variables. I need whatever variables are passed to be comb

Working with popups and such in a class
I've recently started building my applications completely enclosed in classes. I like the fact that

present value of sequence?
Hi

Please help me to find out the present value of sequence?

Thanks

Batch Session SM35 stuck in status 'in Background
Hi Experts,

I am facing a problem with Batch Input session SM35.

The batch se

PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Her

Changing files over
Just thought I'd start with the new forums looking really nice .

Ok basically I've made this

problem in program for counting no of chars using pointers
Hi all, I was trying to make a program which counts number of chars in a string using concpt of poin

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash