fat creative Posted February 9, 2009 Share Posted February 9, 2009 I am trying to send a variable (state = selection) from Flash to PHP, have that pull records from my database and then return the information to Flash in a new Frame. I cannot get it to work. When my PHP file (therapist.php) says to select everything from the table, it works fine. But when I try to get it to select what was passed from Flash, it will not work. I think it's not passing anything from therapists.php to therapists2.php, but I'm not sure how to get it to do that. Therapists2.php is creating an xml file. When I put everything into one file, I get an error message which is why I split it into two files. My scripst are as follows: frame name therapist_select actionscript stop(); var serverLang:String = "asp"; //Create a loadvars object named email_lv var state_search_lv:LoadVars = new LoadVars(); //this function is called when email_lv loads the server-side script. state_search_lv.onLoad = function(success) { if (success) { if (state_search_lv.state_search_mes == "ok") { gotoAndPlay ("therapist"); } } else { search_status_txt.text = "failed"; } }; state_search_btn.onRelease = function() { if (!state_list.selected) { search_status_txt.text = "Select state"; } else { state_search_lv.state_list = state_list.getValue(); state_search_lv.sendAndLoad("http://www.fatcreative.com/mmbr/therapists.php", state_search_lv, "POST"); } }; Frame name therapist actionscript = var xml:XML = new XML(); xml.ignoreWhite = true; xml.onLoad = function() { theTree.dataProvider = this.firstChild; } xml.load("http://www.fatcreative.com/mmbr/therapists2.php"); var treeL:Object = new Object(); treeL.change = function() { var item = theTree.selectedItem; var desc = item.attributes.description; var earl = item.attributes.url; if(earl) { getURL(earl,"_self"); } } theTree.addEventListener("change",treeL); theTree.setStyle("indentation", 20); theTree.setStyle("disclosureOpenIcon","TreeDisclosureOpen"); theTree.setStyle("disclosureClosedIcon","TreeDisclosureClosed"); theTree.setStyle("folderClosedIcon", "blankicon"); theTree.setStyle("folderOpenIcon", "blankicon"); theTree.setStyle ("defaultLeafIcon","blankicon"); stop(); therapists.php file $state = $_POST['state_list']; $ok = $query = "SELECT * FROM therapists"; //this line sends the mail and returns true or false if($ok) { echo "&state_search_mes=ok&"; //if mail was send print to the screen "&server_mes=ok" } else { echo "&state_search_mes=fail&"; // if mail was NOT sent, print to the screen "&server_mes=fail" } //$query = "SELECT * FROM therapists WHERE state = $state"; $query = "SELECT * FROM therapists"; $results = mysql_query($query); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; echo "<therapists>\n"; while ($line = mysql_fetch_assoc($results)) { echo "<folder label=\"" . $line["name"] ."\" >\n"; echo "<info label=\"- Specialty: " . $line["modality"] ."\" />\n"; echo "<info label=\"- Price Range: " . $line["price_range"] ."\" />\n"; echo "<info label=\"- Gender: " . $line["gender"] ."\" />\n"; echo "<info label=\"- Licensed: " . $line["licensed"] ."\" />\n"; echo "<info label=\"- Years of Experience: " . $line["years_exp"] ."\" />\n"; echo "<info label=\"Visit My Page\" " . "url=\"" . $line["website"] ."\" />\n"; echo "</folder> \n"; } echo "\n"; echo "</therapists>\n"; therapists2.php file $query = "SELECT * FROM therapists"; $results = mysql_query($query); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; echo "<therapists>\n"; while ($line = mysql_fetch_assoc($results)) { echo "<folder label=\"" . $line["name"] ."\" >\n"; echo "<info label=\"- Specialty: " . $line["modality"] ."\" />\n"; echo "<info label=\"- Price Range: " . $line["price_range"] ."\" />\n"; echo "<info label=\"- Gender: " . $line["gender"] ."\" />\n"; echo "<info label=\"- Licensed: " . $line["licensed"] ."\" />\n"; echo "<info label=\"- Years of Experience: " . $line["years_exp"] ."\" />\n"; echo "<info label=\"Visit My Page\" " . "url=\"" . $line["website"] ."\" />\n"; echo "</folder> \n"; } echo "\n"; echo "</therapists>\n"; Does anyone have any idea how to pass the variable from one file to the other? I also tried starting a session, but I got error messages with that one too. Or is there another way of doing this? I am new to AS, and just a beginner with PHP, so any help would be greatly appreciated. The site can be seen at http://www.FatCreative.com/mmbr and the action all takes place when you click on the Find a therapist link. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/144406-passing-variables-from-flash-to-php-and-back-to-flash-again/ Share on other sites More sharing options...
RichardRotterdam Posted February 9, 2009 Share Posted February 9, 2009 Hmm haven't used flash in a long while. But when I did I used amfphp to make remote calls a lot easier maybe you'd like to look into it. http://www.amfphp.org/ Quote Link to comment https://forums.phpfreaks.com/topic/144406-passing-variables-from-flash-to-php-and-back-to-flash-again/#findComment-758023 Share on other sites More sharing options...
fat creative Posted February 11, 2009 Author Share Posted February 11, 2009 Thanks for the response. I looked over the amfphp thing and its honestly greek to me. If there are any other suggestions, I would very much appreciate it. I'm afraid the amf will take me the rest of the year to figure out. Quote Link to comment https://forums.phpfreaks.com/topic/144406-passing-variables-from-flash-to-php-and-back-to-flash-again/#findComment-759364 Share on other sites More sharing options...
alphanumetrix Posted February 14, 2009 Share Posted February 14, 2009 lol... it's not so complicated, man. Here's an example of how to load a variable from PHP to flash: AS loadVariablesNum("vars.php",1); if ( _level1.testVar == "itsavar" ) { // execute } PHP: <?php $MyVar = 'itsavar'; echo 'testVar=', $MyVar,''; ?> From there, you change $MyVar based on what your script needs. I didn't bother to read your code, but the thing most people have trouble with when loading variables from PHP to flash is they don't realize that they're based on levels. The variable I pulled from that file is one level 1, and therefore, I had to define that. To do the opposite (flash to PHP), you just have to execute $_POST, just as you would in PHP. You should be able to figure that much out. Quote Link to comment https://forums.phpfreaks.com/topic/144406-passing-variables-from-flash-to-php-and-back-to-flash-again/#findComment-761748 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.