Skip to main content
Known Participant
November 19, 2021
Question

localhost is returning php script to AIR as a string instead of running the script

  • November 19, 2021
  • 1 reply
  • 196 views

Hi

 

I'm having this weird issue where logging into my production and test servers from my AIR desktop app works fine, but when running on localhost the php returns itself as a string to the app (it should be returning JSON).

 

The paths are set up ok, as the app's update checker, which runs first, communicates with the server fine.

 

Here's the basics of the AS3 code that has worked fine for years on the production server, adapted for localhost (_uploadObj cotain vars for post):

 

var array:Array = new Array();
array.push(_uploadObj);
var request:URLRequest = new URLRequest("http://localhost/login/login.php);
request.method = URLRequestMethod.POST;
var sendVars:URLVariables = new URLVariables();
sendVars.userData = JSON.stringify(array);
sendVars.token = _token;
request.data = sendVars;
_loader.load(request);

_loader.addEventListener(Event.COMPLETE, completeFunc);
_uploader._loader.addEventListener(IOErrorEvent.IO_ERROR, displayErrorMessage);



I have a trace set up in the first line in completeFunc(), and it traces the following:

 

<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/../pal/v1.074/login.php';

?>

 

...which is exactly what's in the login.php script that AS3 connects with.

 

Why is it returning the script instead of running it? PHP is running fine in WAMP as the site itsef loads ok in localhost.

 

Thank you

    This topic has been closed for replies.

    1 reply

    Known Participant
    November 19, 2021

    My post here shows I've missed a double quote in the URL, but it's not like that in the actual AS3 code, just in my botched copy/paste to here.