0

Problem:

I call a PHP file using an HTTPService. I set the result of this HTTPService to a function which populates a testTextArea with whatever the PHP file has returned (echoed). This work fine when I run the application from flash builder i.e. I get strings in the testTextArea, echoed by my PHP file. But this does not work fine when I make the Release of the project and the testTextArea gets populated by the whole code of PHP file.

Code:

     private function addUserServiceHandler(event:ResultEvent):void{
            testTextArea.text = event.result.toString(); //This outputs the whole php file in to the textArea as if it were a string
        }


        private function saveButtonClicked():void{
            addUserService.send();
        }

    ]]>
</fx:Script>

<fx:Declarations>
    <mx:HTTPService id="addUserService" url="addUser.php" resultFormat="text" method="POST" result="addUserServiceHandler(event)" >
        <mx:request xmlns="">
            <firstName>{firstNameTextInput.text}</firstName>
            <lastName>{lastNameTextInput.text}</lastName>
            <imageName>{uploadTextInput.text}</imageName>
            <adultContent>{adultContentRadioGroup.selectedValue}</adultContent>
            <p2p>{p2pRadioGroup.selectedValue}</p2p>
            <priority>{priorityRadioGroup.selectedValue}</priority>
        </mx:request>
    </mx:HTTPService>
<fx:Declarations>



<s:Button id="saveButton" includeIn="AddUser" x="313" y="128" label="Save" width="187" height="33" click="saveButtonClicked()"/>
Uthman
  • 9,251
  • 18
  • 74
  • 104
  • could this simply be a `crossdomain.xml` problem? – Jakub Feb 23 '11 at 15:31
  • No idea...Never faced this problem when I used to work with Flex 3 – Uthman Feb 23 '11 at 15:44
  • Well do you HAVE a crossdomain.xml file present with access to that PHP file? I'm assuming it might be blocked.. why not try debugging on the fly? I can't tell you whats wrong, I'm giving suggestions you need to have the 'idea' – Jakub Feb 23 '11 at 15:48
  • lol...you are going to become more angry at me after reading following: Couldn't find crossdomain.xml but the problem was arising because I was mistakenly running my html file from harddisk by double clicking it i.e. I wasn't running it with http://localhost :P – Uthman Feb 24 '11 at 05:59
  • Thanks for sparing time to help me out. :) PEACE – Uthman Feb 24 '11 at 05:59

2 Answers2

0

Is the production server configured to serve PHP files? It sounds like your web server is serving the PHP file as as text file.

Place an info.php file on your production server (in the same directory as addUser.php) with the following contents:

<?php
phpinfo();
?>

and then navigate directly to it in your browser. If you see the above text as-is, then you will need to get PHP working.

jdusbabek
  • 171
  • 1
  • 6
  • Thanks jdusbabek. I was mistakenly not running the html file with http://localhost. That's why the problem was arising.. – Uthman Feb 24 '11 at 06:01
0

The problem was arising because I was mistakenly running my html file from harddisk by double clicking it i.e. I wasn't running it with localhost.

Uthman
  • 9,251
  • 18
  • 74
  • 104