Problem with running PHP file with the Release of Flex project

190 Views Asked by At

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()"/>
2

There are 2 best solutions below

0
On BEST ANSWER

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.

1
On

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.