Problem php mysql ajax

0 favourites
  • 7 posts
From the Asset Store
Paypal PHP Supports multiple platforms, Web/html5 Android, IOS. (Including storing transaction data)
  • Hi to all..

    I have solved all problem with get username from gplay etc..

    Now..

    The game post all data..

    Using fast Ajax...

    Now,

    I have this unique data "userid"

    One ready page with get userid and list of the restult..

    I don't remember, with ajax , from get data from url like ""userpoints.php"

    the request to send userid and get data from it in construct...

    I don't remember how to use it..

    Thank you..

  • I am a little confused in what you are asking to do have you got a PHP script that already does this and you want to use it with construct ?

    Basically you do

    on start of layout ---> ajax request URL to your file

    On get request complete ---> set variable to ajax.lastData

  • Yes, but i need result from player name stored in mysql database..

    :)

    in sql ok, in construct with ajax i have problem .. i think only today problem :)

    get data from url like "playerrestult.php?playername" ... this is my problem for get data from url... i have used it many year ago but now i don't remember..

  • Yes, but i need result from player name stored in mysql database..

    :)

    in sql ok, in construct with ajax i have problem .. i think only today problem :)

    get data from url like "playerrestult.php?playername" ... this is my problem for get data from url... i have used it many year ago but now i don't remember..

    Ok do you get any errors with construct or have you not tried this yet.

    if you want to get data from a URL containing PHP variables eg: ?playername=111

    what you can do is in your ajax get request you would do

    "yoursite.com?playername="&variableInConstruct&"&id="&variableinconstruct

    where you are parsing playername

    id

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I use mysite.com/myfile.php?user="userstoredinConstruct"&

    in the myfile..

    the sql code write to me the score of the user..

    sql_" select score from mytable where user='$user' etc..";

    $result = $conn->query($sql);

    if ($result->num_rows > 0) {

    while($row = $result->fetch_assoc()) {

    echo "".$row["score"]." ".$row["user"]."";

    }

    } else {

    echo "0 results";

    }

    $conn->close();

    All this ok...

    "but not in construct using Ajax"

    get the result? how to do?= with lost data? only?

    Thank you..

  • Does your code work when you visit the URL in your browser?

    Have you checked the console when you run the request in construct - could be a number of errors have you got cross origin allowed on your script?

    when you run your project press:

    ctrl

    shift

    I

    to open developer console then go to network tab and see if there are any errors with your request.

  • header('Access-Control-Allow-Origin: *');

    #header('Access-Control-Allow-Methods: GET, POST');

    now work..

    i have added in one file the control methods..

    Thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)