Note that there are some explanatory texts on larger screens.

plurals
  1. POcommunicating between flex php
    primarykey
    data
    text
    <p>This is my first flex application i have written a php class for the purpose of getting the results from the database. the service definitely works but i'm having difficulty getting flash to list the results and don't understand how i can call the function from within flash properly.</p> <p>heres the php:</p> <pre><code>&lt;?php class CityService { public function getCitys($q) { $con = mysqli_connect('host', 'user', 'password','database') or die(mysqli_connect_error()); $sql="SELECT * FROM city WHERE countrycode ='".$q."'"; $result = mysqli_query($con, $sql) or die('query Failed: ' . mysqli_error($con)); $rows = array(); while($row = mysqli_fetch_object($result)) { $rows[] = $row; } return $rows; } } ?&gt; </code></pre> <p>then i try to pick up the function in flash and display results according to the value given for $q but flash doesn't display the results, when i set the service up it all shows it to be working and can get results back in builder but when i try set everything up <code>mxml</code> and then run it i get nothing back</p> <p>this is a sample of the flash mxml with all the relevant parts:</p> <pre><code> &lt;fx:Script&gt;&lt;![CDATA[ import com.adobe.serializers.utility.TypeUtility; import mx.controls.Alert; import mx.events.FlexEvent; protected function button_clickHandler_100():void { currentState='data'; } protected function dataGrid_creationCompleteHandler(event:FlexEvent):void { getCitysResult.token = cityservice.getCitys('GB'); } ]]&gt;&lt;/fx:Script&gt; &lt;s:states&gt; &lt;s:State fc:color="0x0003a3" name="europe"/&gt; &lt;s:State name="data" fc:color="0x0081cc"/&gt; &lt;/s:states&gt; &lt;fx:Declarations&gt; &lt;s:CallResponder id="getCitysResult"/&gt; &lt;cityservice:Cityservice id="cityservice" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/&gt; &lt;/fx:Declarations&gt; &lt;s:Button click="button_clickHandler_100()" id="button128" includeIn="europe" skinClass="components.englandButton" x="101" y="135"/&gt; &lt;mx:DataGrid includeIn="data" x="23" y="37" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getCitysResult.lastResult}"&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn headerText="citycode" dataField="citycode"/&gt; &lt;mx:DataGridColumn headerText="id" dataField="id"/&gt; &lt;mx:DataGridColumn headerText="countrycode" dataField="countrycode"/&gt; &lt;mx:DataGridColumn headerText="city" dataField="city"/&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; </code></pre> <p>am i missing something here? apart from the rest of the design layer, am i giving the value to cities php service properly? how could i bind GB to the button and supply that back to the cities function that way? also the main problem i'm getting no results when i go to the page???</p> <p>this is the actionscript:</p> <pre><code>package services.cityservice { public class Cityservice extends _Super_Cityservice { } } </code></pre> <p>and also the getCitys function</p> <pre><code>package services.cityservice { import com.adobe.fiber.core.model_internal; import com.adobe.fiber.services.wrapper.RemoteObjectServiceWrapper; import com.adobe.serializers.utility.TypeUtility; import mx.rpc.AbstractOperation; import mx.rpc.AsyncToken; import mx.rpc.remoting.Operation; import mx.rpc.remoting.RemoteObject; import valueObjects.Citydata; import mx.collections.ItemResponder; import com.adobe.fiber.valueobjects.AvailablePropertyIterator; [ExcludeClass] internal class _Super_Cityservice extends com.adobe.fiber.services.wrapper.RemoteObjectServiceWrapper { // Constructor public function _Super_Cityservice() { // initialize service control _serviceControl = new mx.rpc.remoting.RemoteObject(); var operations:Object = new Object(); var operation:mx.rpc.remoting.Operation; operation = new mx.rpc.remoting.Operation(null, "getCitys"); operation.resultElementType = valueObjects.Citydata; operations["getCitys"] = operation; valueObjects.Citydata._initRemoteClassAlias(); _serviceControl.operations = operations; _serviceControl.convertResultHandler = com.adobe.serializers.utility.TypeUtility.convertResultHandler; _serviceControl.source = "cityservice"; _serviceControl.endpoint = "gateway.php"; destination = "cityservice"; model_internal::initialize(); } public function getCitys(q:Object) : mx.rpc.AsyncToken { var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("getCitys"); var _internal_token:mx.rpc.AsyncToken = _internal_operation.send(q) ; return _internal_token; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload