Page 1 of 1

Inserting arrays, received from Flash Mx, to mysql using php

Posted: Sat Feb 07, 2004 1:04 pm
by markjm
Hello,

I am currently trying to send arrays from flash to php. Sending is no problem. However I'm having problems linking the flash array to php variables. I am trying to receive the flash array like this:

Code: Select all

<?php
for ($n = 0; $n < 29; $n++){ 
$header[$n] = $_POST['header' . $n]; 
}
?>
or like this

Code: Select all

<?php
 for ($n = 0; $n < 29; $n++){ 
$header[$n] = $_POST['header[$n]'];
}
?>
and then I'm trying to insert this array into the mySql like so:

Code: Select all

<?php
$ins_tab = "insert into piSavedGames values
(NULL,
'$user',
'$pass',
'$savedGameName',
'$newBookPageCount'"
.join(',', $header);
?>
However I am having no luck. If anyone could give me any idea of what the normal procedure is, I would be deliriously happy. It is such a simple thing and I'm spending so much time on it,

thank you for your time in advance,

Mark Matthews

Posted: Sat Feb 07, 2004 2:19 pm
by Weirdan
First of all you need to check how that array is passed to PHP. Use this snippet:

Code: Select all

.....
print_r($_POST);
.....
post the results here, because not everyone know how Flash passes arrays (personally I don't know ;) )

Posted: Mon Feb 09, 2004 9:36 am
by markjm
hello and thanks Weirdan,

I mistakenly assumed that everyone knows how Flash passes arrays.
Jumping from flash forum to php to mysql confuses me :?
but anyvay,

as far as I know flash sends an array like so, or so I've learned over at http://www.sephiroth.it:

Code: Select all

myarray  = (1,2,3,4,5,8);
which would mean that

Code: Select all

$header = explode(",", $_POST&#1111;'myarray']);
would convert it to a php array??
So all that remains is to work out how to add this to an insert statement,
I'm blindly using something like this....

Code: Select all

$ins_tab = "insert into piSavedGames values 
(NULL, 
'$user', 
 '$bookPageCount'" 
.join(',', $header);
which I learned from an earlier post,

thanks for the help,

MM