I can only swear this to the entire list:

Before I come here for help, each time, I echo and var_dump and print_r until, yes, I need a doctor.

So by the time I come here, it's not laziness or lack of looking in the manual, it's head-swirling confusion infused with incompetence and a complete lack of programming experience at any time before April of this year which leads me to come back again and again with relatively foolish questions.


My problem before, for example: In my error check function, I placed the include file (to return to the form) *within* the foreach loop, and then I wondered why it only ran through once.

D'oh.



Jochem Maas wrote:
Jack Jackson wrote:

AAarg.


Okay, thanks to all of you I've decided that any field name I need to see will be sent to $_SESSION['required_fields'] and basta.

Then after the submit button is pressed, I am doing this:



reset($_SESSION['required_fields']);


reset is not required when using foreach. and given that you have probably
not looped that item

  foreach ($_SESSION['required_fields'] as $fieldname)
    {
       if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname]))
        {
        $message[$fieldname]=1;
        include_once(QUESTIONS . 'q.inc');
        }
    }//error check



you may be getting into trouble because of php's typecasting - try using
fielnames that are strings that do not auto cast to integers (which can be
used as array keys for indexed arrays) e.g. "cb1" instead of "1"


And this is *almost* working: it seems to crap out after the first loop through the $_SESSION['required_field'] array.

The array says:

Array ( [required_fields] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 1 [5] => 2 [6] => 3 [7] => 4 [8] => 1 [9] => 2 [10] => 3 [11] => 4 ) )

$_POST says:

Array ( [action] => [process]process [1] => [2] => 68 [3] => [4] => )


that does not look like valid output from var_dump() neither does the output you
show for $_SESSION['required_field'].


So you see, there's an answer specified for the value of question [2].

But $messages says only:

$message: array(1) { [1]=>  int(1) }


Why is it dying after the first loop through?


is it? (use print_r() or var_dump() inside the loop to see what is happening)

NOT SO SUBTLE HINT: USE echo, print_r() and var_dump() until either you fingers or your eyes start to bleed ;-) if you still haven't figured it out by then it's
time to see a doctor -









Thanks in advance





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to