Page 1 of 1

array_sum() argument not an array

Posted: Fri Apr 23, 2010 9:02 am
by Bill H
I have the array in an include file,

Code: Select all

     $Qcnt = array(1=>array(1=>array(4,4,1,2,4),2=>array(4,4,1,2,4),3=>array(6,3,1,5,4),4=>array(3,3,1,5,4)),           // number of questions
                   2=>array(1=>array(4,4,1,2,4),2=>array(4,4,1,2,4),3=>array(6,3,1,5,4),4=>array(3,3,1,5,4)));          // in each segment

     $CurrVer = 1;                      // applies to shopper creation and blank forms
in a file using that is the following,

Code: Select all

if (isset($_POST['Basic']))                   // updating at basic level, moving on or not (status is zero)
{                                                  // $_POST['Basic'] is the report type (1-4)
     $Typ = array_sum($Qcnt[$CurrVer][$_POST['Basic']]);         // some have more questions than others
and I get the error "The argument should be an array" for the "$Typ=" line.
Echoing the vars says that $_POST['Basic'] = 2 and $CurrVer = 1
Why is the argument not an array?

Re: array_sum() argument not an array

Posted: Fri Apr 23, 2010 9:14 am
by John Cartwright
What does

Code: Select all

var_export($Qcnt[$CurrVer][$_POST['Basic']]);


say?

Re: array_sum() argument not an array

Posted: Fri Apr 23, 2010 11:02 am
by Bill H
Well, this is getting wierd,

Code: Select all

array ( 0 => 4, 1 => 4, 2 => 1, 3 => 2, 4 => 4, )
I'm going to kill this client. I swear, I'm going to kill her. Dead.

I decided to go try the function in question and, guess what, I don't get the error. It may be that her browser was caching the include file, I don't know, but I don't get the furshlugginer error. It processes the form precisely as it is supposed to do, using all four browsers that I test with.

I'll tell her to clear cache, reboot her damn computer if need be, and try again.

Sorry.