Hi there,
I have a very basic code which is not working! It’s driving me half crazy!
For some reason, the complete handler is not working! it is not returning the result of the count… I can’t understand why?! What have i done wrong?
Here is my flash code:
var theRequest:URLRequest = new URLRequest();
theRequest.url = "getData3.php";
theRequest.method = URLRequestMethod.POST;
var theLoader:URLLoader = new URLLoader();
theLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
theLoader.addEventListener(Event.COMPLETE, loadCompleteHandler);
theLoader.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
theLoader.load(theRequest);
function handleIOError(event:IOErrorEvent):void {
event.target.removeEventListener(IOErrorEvent.IO_ERROR, handleIOError);
}
function loadCompleteHandler(evt:Event):void {
MovieClip(root).mcMessage.showMessage("this is it: "+evt.target.data.count);
MovieClip(root).mcMessage.visible = true;
}
php code (correctly returning results, including “count=8”):
@require_once ('database.php');
$sql = "SELECT * FROM `Saved_products`";
$result = mysql_query($sql);
$count = 0;
while($row = mysql_fetch_array($result)){
echo "product_name $count=".utf8_encode($row[product_name])."& product_descr $count=".utf8_encode($row[product_descr])"&";
$count++;
}
echo "count=$count"."&";