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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
markjm
Forum Newbie
Posts: 4
Joined: Tue Feb 03, 2004 6:26 am

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

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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 ;) )
markjm
Forum Newbie
Posts: 4
Joined: Tue Feb 03, 2004 6:26 am

Post 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
Post Reply