RE: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Thanks Glen! This is what I was looking for. I use URLVariables in many occasions, but that is always like 1 record. The (multi-records)part in php is really my problem. I think I can work-out your example! Thanks again! Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: dinsdag 6 september 2011 22:35 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP Hi, You can post multidimensional arrays to PHP for example in an HTML form, this is better than GET which may have a lower limit on the number of characters that can be sent in a request (as I found out with some JQuery stuff)... http://php.net/manual/en/reserved.variables.post.php http://www.php.net/manual/en/reserved.variables.post.php#96902 You can do: input name=myArray[0][id] value=123/ So in Flash you could do the same by setting the appropriate variables in a URLVariables, but note, you probably have to call your variables something like this: var data:URLVariables = new URLVariables(); data[myArray[0][id]] = 123; So you could loop through your datagrid and submit the values that way - you would need to add a count variable which tells PHP how many objects are in your array, then you could do: ?php $num_items = isset($_POST['num_items']) ? (int)$_POST['num_items'] : 0; for($i = 0; $i $num_items;$i++) { $id = $_POST[myArray][$i][id]; //... } ? Alternatively - and less data-intensively, you could save the values every time someone changes a field and then it loses focus. You would have to save each variable separately so you would need a form processor that handles some kind of id, a variable name and a value that you then add / update in the database (if there is no id field, you could be inserting data). You could use Sephiroth's serialiazer system: http://www.sephiroth.it/test/unserializer/ Or some other way of dealing with the data like AMF, etc. There used to be some good stuff on Flash DB http://www.flash-db.com/, but it appears to be down now, so maybe it has gone the way of many websites... I think there are lots of libraries that do a lot of the crappy grunt work for you with Flash - Database stuff so whilst it's good to learn the principles, you would possibly benefit from finding something like these in the long run, especially where security is concerned: http://www.php.net/manual/en/security.database.php Hope this helps you a little. If only you could assign an object to URLVariables and have it post properly Glen On 06/09/2011 04:04, Cor wrote: Thanks Karl, Yes, I know. My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] myArray[1[id] myArray[1][name] myArray[1][description] myArray[2[id] myArray[2][name] myArray[2][description] etc. Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: dinsdag 6 september 2011 3:54 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP Hi Cor, Assuming you know enough php to set up the file for connecting to your database, you can insert into your database with the following example. function addDescription($id, $name, $description) { //Escape any data being inserted $id = mysql_real_escape_string($id); $name = mysql_real_escape_string($name); $description = mysql_real_escape_string($description); $query = INSERT INTO YOUR_TABLE_NAME_HERE VALUES ('.$id.','. $name.','.description.'); $_POST['VALUES']; $result = mysql_query($query, YOUR_CONNECTION) or die(mysql_error()); return $result; //Returns true or false if error } HTH, Best, Karl On Sep 5, 2011, at 2:04 PM, Cor wrote: I have a editable datagrid which I fill from mySQL with PHP. So far works good. But when items are changed (edit, added, deleted), I want them to save the data in my mySQL database. My values are in this multi-dimensional indexed array, which elements all contain a associative array: myArray[i][id] myArray[i][name] myArray[i][description] So, can anyone tell/show me a apropriate way to pass this to PHP and in the php-file how to INSERT or UPDATE this to mySQL? TIA! Best regards, Cor van Dooren ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Hi, You can post multidimensional arrays to PHP for example in an HTML form, this is better than GET which may have a lower limit on the number of characters that can be sent in a request (as I found out with some JQuery stuff)... http://php.net/manual/en/reserved.variables.post.php http://www.php.net/manual/en/reserved.variables.post.php#96902 You can do: input name=myArray[0][id] value=123/ So in Flash you could do the same by setting the appropriate variables in a URLVariables, but note, you probably have to call your variables something like this: var data:URLVariables = new URLVariables(); data[myArray[0][id]] = 123; So you could loop through your datagrid and submit the values that way - you would need to add a count variable which tells PHP how many objects are in your array, then you could do: ?php $num_items = isset($_POST['num_items']) ? (int)$_POST['num_items'] : 0; for($i = 0; $i $num_items;$i++) { $id = $_POST[myArray][$i][id]; //... } ? Alternatively - and less data-intensively, you could save the values every time someone changes a field and then it loses focus. You would have to save each variable separately so you would need a form processor that handles some kind of id, a variable name and a value that you then add / update in the database (if there is no id field, you could be inserting data). You could use Sephiroth's serialiazer system: http://www.sephiroth.it/test/unserializer/ Or some other way of dealing with the data like AMF, etc. There used to be some good stuff on Flash DB http://www.flash-db.com/, but it appears to be down now, so maybe it has gone the way of many websites... I think there are lots of libraries that do a lot of the crappy grunt work for you with Flash - Database stuff so whilst it's good to learn the principles, you would possibly benefit from finding something like these in the long run, especially where security is concerned: http://www.php.net/manual/en/security.database.php Hope this helps you a little. If only you could assign an object to URLVariables and have it post properly Glen On 06/09/2011 04:04, Cor wrote: Thanks Karl, Yes, I know. My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] myArray[1[id] myArray[1][name] myArray[1][description] myArray[2[id] myArray[2][name] myArray[2][description] etc. Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: dinsdag 6 september 2011 3:54 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP Hi Cor, Assuming you know enough php to set up the file for connecting to your database, you can insert into your database with the following example. function addDescription($id, $name, $description) { //Escape any data being inserted $id = mysql_real_escape_string($id); $name = mysql_real_escape_string($name); $description = mysql_real_escape_string($description); $query = INSERT INTO YOUR_TABLE_NAME_HERE VALUES ('.$id.','. $name.','.description.'); $_POST['VALUES']; $result = mysql_query($query, YOUR_CONNECTION) or die(mysql_error()); return $result; //Returns true or false if error } HTH, Best, Karl On Sep 5, 2011, at 2:04 PM, Cor wrote: I have a editable datagrid which I fill from mySQL with PHP. So far works good. But when items are changed (edit, added, deleted), I want them to save the data in my mySQL database. My values are in this multi-dimensional indexed array, which elements all contain a associative array: myArray[i][id] myArray[i][name] myArray[i][description] So, can anyone tell/show me a apropriate way to pass this to PHP and in the php-file how to INSERT or UPDATE this to mySQL? TIA! Best regards, Cor van Dooren ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Hi Cor, Assuming you know enough php to set up the file for connecting to your database, you can insert into your database with the following example. function addDescription($id, $name, $description) { //Escape any data being inserted $id = mysql_real_escape_string($id); $name = mysql_real_escape_string($name); $description = mysql_real_escape_string($description); $query = INSERT INTO YOUR_TABLE_NAME_HERE VALUES ('.$id.','. $name.','.description.'); $_POST['VALUES']; $result = mysql_query($query, YOUR_CONNECTION) or die(mysql_error()); return $result; //Returns true or false if error } HTH, Best, Karl On Sep 5, 2011, at 2:04 PM, Cor wrote: I have a editable datagrid which I fill from mySQL with PHP. So far works good. But when items are changed (edit, added, deleted), I want them to save the data in my mySQL database. My values are in this multi-dimensional indexed array, which elements all contain a associative array: myArray[i][id] myArray[i][name] myArray[i][description] So, can anyone tell/show me a apropriate way to pass this to PHP and in the php-file how to INSERT or UPDATE this to mySQL? TIA! Best regards, Cor van Dooren ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Thanks Karl, Yes, I know. My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] myArray[1[id] myArray[1][name] myArray[1][description] myArray[2[id] myArray[2][name] myArray[2][description] etc. Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: dinsdag 6 september 2011 3:54 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP Hi Cor, Assuming you know enough php to set up the file for connecting to your database, you can insert into your database with the following example. function addDescription($id, $name, $description) { //Escape any data being inserted $id = mysql_real_escape_string($id); $name = mysql_real_escape_string($name); $description = mysql_real_escape_string($description); $query = INSERT INTO YOUR_TABLE_NAME_HERE VALUES ('.$id.','. $name.','.description.'); $_POST['VALUES']; $result = mysql_query($query, YOUR_CONNECTION) or die(mysql_error()); return $result; //Returns true or false if error } HTH, Best, Karl On Sep 5, 2011, at 2:04 PM, Cor wrote: I have a editable datagrid which I fill from mySQL with PHP. So far works good. But when items are changed (edit, added, deleted), I want them to save the data in my mySQL database. My values are in this multi-dimensional indexed array, which elements all contain a associative array: myArray[i][id] myArray[i][name] myArray[i][description] So, can anyone tell/show me a apropriate way to pass this to PHP and in the php-file how to INSERT or UPDATE this to mySQL? TIA! Best regards, Cor van Dooren ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); form_varSend=new URLRequest(Main.PHP_URL+control.php); form_varSend.method=URLRequestMethod.POST; form_varSend.data=form_variables; form_varLoader=new URLLoader ; form_varLoader.dataFormat=URLLoaderDataFormat.VARIABLES; form_variables.sendRequest = registreer_materiaal; form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 5:27 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Hi Cor, Have you ever made a mail form in flash? I am assuming you have. Pretty much same scenario. Just break down myArray[i] into individual vars and send the variables to the php file. So with a while or for loop, gather all your variables and send away. Opt 1. for each set - myArray[0] - send this set return to for loop - myArray[1] - send next set ... etc Opt 2. or gather all the individual variables and send all at once. if this is your wish. you will have to set something up on the php side to differentiate between myArray[0]['id'] and myArray[1]['id'], etc. 3. or you can send the array and break it up on the php side with a while or for loop var $ID_Array = array(); for () { $ID_Array[i] = array(); $this-$ID_Array[i][0] = $_POST[id][0]; (This is not tested, FYI. just the basic gist) When you use POST in flash, php will automatically fill $_POS[''] with the flash form var. then you just get your var out and put it in that function. $post_id = $_POST['id']; $post_name = $_POST['name']; $post_description = $_POST['description']; $database_query = $database-addDescription($post_id, $post_name, $post_description); if($database_query){ //True ? False Success / fail code other ... } I should mention that I use this stuff inside php classes. so $this- has already been defined as the class your currently in. Like the database class, $database-addDescription(); is called outside the class. if it was called inside the database class file, it would be $this-addDescription();. Also, the php file name thats called from flash is database.php. etc, etc. FYI. I would recommend setting up separate php files - a process.php, this retrieves your variables from flash, makes sure its not a bot, any verify codes checked here, etc - then send it to your sessions.php for validation and set your errors here to send back with. - then send to your database.php for stripping, manipulation and insertion. to send back to flash, use die('Error example') for errors and use a status listener in flash to send results, use the return($result); A search for php sessions example or php login example would get you a workable sample code. HTH, Best, Karl On Sep 5, 2011, at 10:04 PM, Cor wrote: Thanks Karl, Yes, I know. My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] myArray[1[id] myArray[1][name] myArray[1][description] myArray[2[id] myArray[2][name] myArray[2][description] etc. Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: dinsdag 6 september 2011 3:54 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP Hi Cor, Assuming you know enough php to set up the file for connecting to your database, you can insert into your database with the following example. function addDescription($id, $name, $description) { //Escape any data being inserted $id = mysql_real_escape_string($id); $name = mysql_real_escape_string($name); $description = mysql_real_escape_string($description); $query = INSERT INTO YOUR_TABLE_NAME_HERE VALUES ('.$id.','. $name.','.description.'); $_POST['VALUES']; $result = mysql_query($query, YOUR_CONNECTION) or die(mysql_error()); return $result; //Returns true or false if error } HTH, Best, Karl On Sep 5, 2011, at 2:04 PM, Cor wrote: I have a editable datagrid which I fill from mySQL with PHP. So far works good. But when items are changed (edit, added, deleted), I want them to save the data in my mySQL database. My values are in this multi-dimensional indexed array, which elements all contain a associative array: myArray[i][id] myArray[i][name] myArray[i][description] So, can anyone tell/show me a apropriate way to pass this to PHP and in the php-file how to INSERT or UPDATE this to mySQL? TIA! Best regards, Cor van Dooren ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
I think you may be able to use the php split() or explode() on a array of data sent. but probably easier to split it up when gathering the info in flash. multiple small queries instead of a bulky single query? Karl On Sep 5, 2011, at 10:34 PM, Cor wrote: Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); form_varSend=new URLRequest(Main.PHP_URL+control.php); form_varSend.method=URLRequestMethod.POST; form_varSend.data=form_variables; form_varLoader=new URLLoader ; form_varLoader.dataFormat=URLLoaderDataFormat.VARIABLES; form_variables.sendRequest = registreer_materiaal; form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 5:27 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); ... form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } That would send a single form field, VALUES, with a single value containing something that's not a string. But sending data via HTTP requires that you use strings. In the simplest case, you'd at least have to convert the array to a string to store it within the single form field. This kind of thing is a fairly common problem with web applications - you typically have to serialize your data to send via HTTP, then deserialize the sent data to use it as an object that's not a string. Normally, as an occasional Flex guy, I end up using AMF which includes serialization/deserialization functionality to handle this for you. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Karl, Thank you very much!! But this would create a lot of network traffic, open connection and database, do mysql_query and close db conn?? You wrote in the previous mail: I should mention that I use this stuff inside php classes. so $this- has already been defined as the class your currently in. Like the database class, $database-addDescription(); is called outside the class. if it was called inside the database class file, it would be $this-addDescription();. Also, the php file name thats called from flash is database.php. etc, etc. FYI. - a process.php, this retrieves your variables from flash, makes sure its not a bot, any verify codes checked here, etc - then send it to your sessions.php for validation and set your errors here to send back with. - then send to your database.php for stripping, manipulation and insertion. This is what I am looking for (to learn) and where my knowledge of PHP stops... You can address me directly if you like: codo AT chello DOT nl Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: dinsdag 6 september 2011 6:07 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP I think you may be able to use the php split() or explode() on a array of data sent. but probably easier to split it up when gathering the info in flash. multiple small queries instead of a bulky single query? Karl On Sep 5, 2011, at 10:34 PM, Cor wrote: Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); form_varSend=new URLRequest(Main.PHP_URL+control.php); form_varSend.method=URLRequestMethod.POST; form_varSend.data=form_variables; form_varLoader=new URLLoader ; form_varLoader.dataFormat=URLLoaderDataFormat.VARIABLES; form_variables.sendRequest = registreer_materiaal; form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 5:27 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Thanks David, OK, HTTP - String... that clears a lot! Can you give a little example of how to do you typically have to serialize your data to send via HTTP, then deserialize the sent data to use it as an object that's not a string. Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 6:08 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); ... form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } That would send a single form field, VALUES, with a single value containing something that's not a string. But sending data via HTTP requires that you use strings. In the simplest case, you'd at least have to convert the array to a string to store it within the single form field. This kind of thing is a fairly common problem with web applications - you typically have to serialize your data to send via HTTP, then deserialize the sent data to use it as an object that's not a string. Normally, as an occasional Flex guy, I end up using AMF which includes serialization/deserialization functionality to handle this for you. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Hey Cor, This is how I have it set up in as2, you may be able to port easier than I. send_btn.onRelease = function() { //Creates a LoadVars and get values from the form mylv = new LoadVars(); myreply = new LoadVars(); mylv.formTrue = 1; //Verify were on our form //could put a while loop here mylv.id = myArray[i]['id']; mylv.id = id.text; mylv.name = name_txt.text; mylv.description = description.text; //Show success or fails message myreply.onLoad = function() { if(this.status === Mail sent!) { //Success! newStatus = this.status + - Thank you for your response. We will get in touch with you at +email_txt.text+.brbr- Company; gotoAndPlay(send_off); } else if(this.status === Mail Failed!){//Mail Failed with error _parent.status = this.status + brSorry there was a problem sending your message. Please try again or try again at a later time. We apologize for any inconvenience.; } else { _parent.status = this.status; } //end while loop here }; mylv.sendAndLoad(http://yourwebsite.com/process.php;, myreply, POST); _parent.status = sending now ...; } Obviously this is for a mail form and needs to be seasoned to taste, but.. HTH, Best, Karl On Sep 5, 2011, at 11:07 PM, Karl DeSaulniers wrote: I think you may be able to use the php split() or explode() on a array of data sent. but probably easier to split it up when gathering the info in flash. multiple small queries instead of a bulky single query? Karl On Sep 5, 2011, at 10:34 PM, Cor wrote: Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); form_varSend=new URLRequest(Main.PHP_URL+control.php); form_varSend.method=URLRequestMethod.POST; form_varSend.data=form_variables; form_varLoader=new URLLoader ; form_varLoader.dataFormat=URLLoaderDataFormat.VARIABLES; form_variables.sendRequest = registreer_materiaal; form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 5:27 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Hi Cor, On Sep 5, 2011, at 11:14 PM, Cor wrote: Karl, Thank you very much!! But this would create a lot of network traffic, open connection and database, do mysql_query and close db conn?? You only need to open it once. Do all your sending and inserting, then close once your done. You wrote in the previous mail: I should mention that I use this stuff inside php classes. so $this- has already been defined as the class your currently in. Like the database class, $database-addDescription(); is called outside the class. if it was called inside the database class file, it would be $this-addDescription();. Also, the php file name thats called from flash is database.php. etc, etc. FYI. - a process.php, this retrieves your variables from flash, makes sure its not a bot, any verify codes checked here, etc - then send it to your sessions.php for validation and set your errors here to send back with. - then send to your database.php for stripping, manipulation and insertion. This is what I am looking for (to learn) and where my knowledge of PHP stops... This is the best way in my opinion. I learned off of finding a php login example. You can address me directly if you like: codo AT chello DOT nl I am available if you need. My email is above. Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: dinsdag 6 september 2011 6:07 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP I think you may be able to use the php split() or explode() on a array of data sent. but probably easier to split it up when gathering the info in flash. multiple small queries instead of a bulky single query? Karl On Sep 5, 2011, at 10:34 PM, Cor wrote: Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); form_varSend=new URLRequest(Main.PHP_URL+control.php); form_varSend.method=URLRequestMethod.POST; form_varSend.data=form_variables; form_varLoader=new URLLoader ; form_varLoader.dataFormat=URLLoaderDataFormat.VARIABLES; form_variables.sendRequest = registreer_materiaal; form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 5:27 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Correction... _parent.status = this.status; } }; mylv.sendAndLoad(http://yourwebsite.com/process.php;, myreply, POST); _parent.status = sending now ...; //end while loop here } Best, Karl On Sep 5, 2011, at 11:20 PM, Karl DeSaulniers wrote: Hey Cor, This is how I have it set up in as2, you may be able to port easier than I. send_btn.onRelease = function() { //Creates a LoadVars and get values from the form mylv = new LoadVars(); myreply = new LoadVars(); mylv.formTrue = 1; //Verify were on our form //could put a while loop here mylv.id = myArray[i]['id']; mylv.id = id.text; mylv.name = name_txt.text; mylv.description = description.text; //Show success or fails message myreply.onLoad = function() { if(this.status === Mail sent!) { //Success! newStatus = this.status + - Thank you for your response. We will get in touch with you at +email_txt.text+.brbr- Company; gotoAndPlay(send_off); } else if(this.status === Mail Failed!){//Mail Failed with error _parent.status = this.status + brSorry there was a problem sending your message. Please try again or try again at a later time. We apologize for any inconvenience.; } else { _parent.status = this.status; } //end while loop here }; mylv.sendAndLoad(http://yourwebsite.com/process.php;, myreply, POST); _parent.status = sending now ...; } Obviously this is for a mail form and needs to be seasoned to taste, but.. HTH, Best, Karl On Sep 5, 2011, at 11:07 PM, Karl DeSaulniers wrote: I think you may be able to use the php split() or explode() on a array of data sent. but probably easier to split it up when gathering the info in flash. multiple small queries instead of a bulky single query? Karl On Sep 5, 2011, at 10:34 PM, Cor wrote: Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); form_varSend=new URLRequest(Main.PHP_URL+control.php); form_varSend.method=URLRequestMethod.POST; form_varSend.data=form_variables; form_varLoader=new URLLoader ; form_varLoader.dataFormat=URLLoaderDataFormat.VARIABLES; form_variables.sendRequest = registreer_materiaal; form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 5:27 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com
RE: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP
Hi Karl, The Flash part is no problem. But in PHP I am a novice! So far I learned that I should think of sending Strings to PHP instead of a complete multi-dim array. I don't know how to set up PHP to open it once. Do all your sending and inserting, then close once I am done? Do you have some examples of your construction with the different files/classes? Best regards, Cor van Dooren -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: dinsdag 6 september 2011 6:24 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP Correction... _parent.status = this.status; } }; mylv.sendAndLoad(http://yourwebsite.com/process.php;, myreply, POST); _parent.status = sending now ...; //end while loop here } Best, Karl On Sep 5, 2011, at 11:20 PM, Karl DeSaulniers wrote: Hey Cor, This is how I have it set up in as2, you may be able to port easier than I. send_btn.onRelease = function() { //Creates a LoadVars and get values from the form mylv = new LoadVars(); myreply = new LoadVars(); mylv.formTrue = 1; //Verify were on our form //could put a while loop here mylv.id = myArray[i]['id']; mylv.id = id.text; mylv.name = name_txt.text; mylv.description = description.text; //Show success or fails message myreply.onLoad = function() { if(this.status === Mail sent!) { //Success! newStatus = this.status + - Thank you for your response. We will get in touch with you at +email_txt.text+.brbr- Company; gotoAndPlay(send_off); } else if(this.status === Mail Failed!){//Mail Failed with error _parent.status = this.status + brSorry there was a problem sending your message. Please try again or try again at a later time. We apologize for any inconvenience.; } else { _parent.status = this.status; } //end while loop here }; mylv.sendAndLoad(http://yourwebsite.com/process.php;, myreply, POST); _parent.status = sending now ...; } Obviously this is for a mail form and needs to be seasoned to taste, but.. HTH, Best, Karl On Sep 5, 2011, at 11:07 PM, Karl DeSaulniers wrote: I think you may be able to use the php split() or explode() on a array of data sent. but probably easier to split it up when gathering the info in flash. multiple small queries instead of a bulky single query? Karl On Sep 5, 2011, at 10:34 PM, Cor wrote: Do you mean that is it not possible to send an array from Flash to PHP in this way: private function validateAndSend(e:MouseEvent):void { form_variables = new URLVariables(); form_varSend=new URLRequest(Main.PHP_URL+control.php); form_varSend.method=URLRequestMethod.POST; form_varSend.data=form_variables; form_varLoader=new URLLoader ; form_varLoader.dataFormat=URLLoaderDataFormat.VARIABLES; form_variables.sendRequest = registreer_materiaal; form_variables.VALUES = myMultiDimArray; form_varLoader.addEventListener(Event.COMPLETE, completeLoadHandler); form_varLoader.load(form_varSend); } -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dave Watts Sent: dinsdag 6 september 2011 5:27 To: Flash Coders List Subject: Re: [Flashcoders] DataGrid: save multidim arrayfrom Flash to mySQL with PHP My problem is how to fetch my $_POST['VALUES'], which is the multi-dimensional array: myArray[0[id] myArray[0][name] myArray[0][description] ... etc. I'm not a PHP expert, but in general you can't really submit an array as form data directly to a CGI program. You have to post name-value pairs - if you have a set of array values, they'd simply end up having the same name and different values (like a checkbox array in HTML, for example). In your case, things are a bit more complicated because you have an array of structs, basically, so you'll need to convert those to a bunch of individual name-value pairs in order to submit them to a CGI program. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http