Re: Problem receiving POSTed data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hang on - my php code may be working fine.  It might be a problem with my
actionscript code - particularly that the LoadVars object I'm using to send
the data might not be able to take multidimensional data (though it
definitely does not say that *anywhere* in the documentation!!).  Stupid
actionscript documentation.

Raphael, here is the code I am using (I am iterating through all of the
movieclips in my flash doc and gathering data on their name and position):

/*****************************************/
for(var i in _level0) {
  if(typeof(_level0[i]) == "movieclip") {
     data_lv[i] = _level0[i];
     data_lv[i].id = _level0[i]._name;
     data_lv[i].x = _level0[i]._x;
     data_lv[i].y = _level0[i]._y;
  }
}
data_lv.sendAndLoad("myScript.php", data_lv, "POST");

/******************************************/

The odd thing is that I print out the contents of data_lv and everything is
there as expected in multidimensional form so I thought that was working
fine, but someone on a flash message board just posted saying they thought
LoadVars objects could not handle multidimensional data.  So maybe even
though the contents of the object print as expected, it doesn't send as
expected.  I'll try this in a completely one-dimensional array from flash to
php and see if it works.  If it does, I'll let everyone know.

Andy

On 10/6/06, Raphael Martins <rafudu.webdesign@xxxxxxxxx> wrote:

Did you explicitly checked if the id1 'a' prop isn´t an array?
Can you post your ActionScript code....maybe it´ll help!

:D

Good Luck

2006/10/6, Andy Hultgren < wearhdphp@xxxxxxxxx>:
>
> Hi everyone,
>
> So, I'm trying to receive POSTed data which is being sent from Flash
> structured as a nested array pictured (conceptually):
>
> "id" contains (a, b, c)
> "a" contains (prop1 => a1, prop2 => a2, ...)
> "b" contains (prop1 => b1, prop2 => b2, ...)
> "c" contains (prop1 => c1, prop2 => c2, ...)
>
> where a1, a2, b1, b2, c1, c2 are values stored in the keys prop1, prop2
> etc.
> of their respective arrays.  That's the conceptual structure, but that
> isn't
> how the information is passed to PHP from Flash.  In Flash (which uses
> "."
> notation for arrays), the data is packaged with a LoadVars object (for
> those
> who care) as follows:
>
> postObject.id1
> postObject.id1.prop1 = a1
> postObject.id1.prop2 = a2
> ...
> postObject.id2.prop1 = b1
> postObject.id2.prop2 = b2
> ...
> etc.
>
> I *think* this data *should be* received by PHP (with dots converted to
> "_" since that's what I've read php does) in the $_POST array as
> follows:
>
> $_POST contains (id1 -> a, id1_prop1 -> a1, id1_prop2 -> a2, ..., id2 ->
> b,
> id2_prop1 -> b1, id2_prop2 -> b2, ...)
>
> However, that's not what I appear to be getting from the $_POST
> array.  When
> I run this code:
>
> /*************************************/
> $data = $_POST;
> $stuff = "\n \n Post contains:";
>
> foreach($data as $prop => $val) {
>      $stuff .= "\n {$prop}: {$val}";
> }
> /*************************************/
>
> and write $stuff to a .txt file, I get the following output:
>
> Post contains:
> id1: a
> id2: b
> id3: c
>
> and that's it!  No information at all about id1_prop1, id1_prop2,
> id2_prop1,
> etc etc.
>
> I am really stuck at this point.  Does anyone know how multidimensional
> information is passed to the $_POST variable?  I know it can be done
> with
> HTML forms and arrays, but I'm using flash and so I think my
> multidimensional array of information simply gets flattened into a
> one-dimensional array when POSTed as a described above (since Flash uses
> dot
> notation for arrays and php changes dots to underscores and just makes
> it
> one long variable name).  And that would work fine if that's what it was
> doing, but, for some reason, $_POST doesn't seem to be receiving the
> second
> array dimension at all which contains all of my property information
> (which
> should have been flattened into the first dimension).
>
> If that's doesn't make any sense please let me know and I will attempt
> to
> clarify.  Otherwise, any and all help is very much appreciated!
>
> Andy
>
>


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux