DuPreez Posted August 23, 2011 Share Posted August 23, 2011 For some reason I cannot POST a value using HTTPService in Flex to my php file. If I hardcode the value in the php it works 100%, using just the HTTPService with GET. I need the xml result as dataProvider for a Flex graph and like I said, it works 100% and the graph displays correctly with a hardcoded value in the php. If I test in the browser like so: http://localhost/...my_url//myfile.php?itemID=1 I get an undefined index error and obviously if I run my Flex application I get no graph. If I change the $_POST to $_GET in php and just test in browser I get the correct output. Please help! Here's the php: <?php header("Content-Type:text/xml"); echo '<data>'; //connection info define("DATABASE_SERVER", "localhost"); define("DATABASE_USERNAME", "root"); define("DATABASE_PASSWORD", ""); define("DATABASE_NAME", "xx"); $dbc = mysqli_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME); $itemID=$_POST['itemID']; $q = "SELECT ID, Name FROM inventory where AreaID = $itemID"; $i=0; $r = mysqli_query($dbc,$q); while ($row=mysqli_fetch_array($r, MYSQLI_ASSOC)){ $i++; echo "<node> <Type>{$row["Designation"]}</Type> <num>{$i}</num> </node> "; } echo '</data>'; ?> Here's the Flex: <s:HTTPService id="testData" url="...my_url/myfile.php" method="GET" resultFormat="e4x" result="xmlHandler(event)"/> <s:HTTPService id="getChartData" url="...my_url/myfile.php" method="POST" resultFormat="text" result="getChartData_resultHandler(event)"> <mx:request> <itemID>{1}</itemID> </mx:request> </s:HTTPService> [bindable] private var testInfo:XMLList; private function xmlHandler(event:ResultEvent):void { testInfo = event.result.node; testChart.dataProvider=testInfo; } protected function getChartData_resultHandler(event:ResultEvent):void { testData.send(); } Link to comment Share on other sites More sharing options...
DuPreez Posted August 23, 2011 Author Share Posted August 23, 2011 Sorry, where is says Designation and Name it's the same thing. That's not the problem. The database query works 100% Link to comment Share on other sites More sharing options...
Larry Posted August 24, 2011 Share Posted August 24, 2011 Well, just out of curiosity, why would you use POST here? To me, POST is inappropriate and GET is the correct request method to use. POST is normally used to change server data; GET used to request server data. Link to comment Share on other sites More sharing options...
DuPreez Posted August 25, 2011 Author Share Posted August 25, 2011 Well, just out of curiosity, why would you use POST here? To me, POST is inappropriate and GET is the correct request method to use. POST is normally used to change server data; GET used to request server data. Hi, thanks for the reply. It is solved. The problem was I never called/invoked the POST HTTPService in my Flex application. However, I've since dropped the POST HTTPService altogether. I'm only using a GET HTTPService with <s:Request/> where I send the itemID data to the server. Also, in my php file I use $_REQUEST, but I know I can also use $_GET. Thanks again. Link to comment Share on other sites More sharing options...
Larry Posted August 25, 2011 Share Posted August 25, 2011 Glad to hear it's resolved and thanks for letting us know. Link to comment Share on other sites More sharing options...
Recommended Posts