AJAX request not returning right value

0 favourites
  • 4 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I am in need of some help, any help is appreciated. I understand that PHP is beyond the scope of Construct 2, however I do know there are some experienced script programmers on these forums.

    What I have is a database named "test" and what im doing is sending an AJAX request from Construct 2 asking for a match between the text in FriendBox (which is a textbox in Construct 2) to my database and return the echoed result into a text plugin named FriendsText.

    However, I do have it all setup, and when I try to put something inside the FriendBox textbox and send the AJAX request to my PHP file, it returns "/ br" every time. I am not sure why it is returning that instead of returning the username from my database.

    Here is the screenshot where I declare an AJAX request inside Construct 2:

    <img src="http://img703.imageshack.us/img703/4387/fwhk.png" border="0" />

    And here is my PHP file that should return username:

    <?php

    $username = $_GET['fname'];

    $con=mysqli_connect("localhost","root","","test");

    // Check connection

    if (mysqli_connect_errno())

    {

    echo "Failed to connect to MySQL: " . mysqli_connect_error();

    }

    $result = mysqli_query($con,"SELECT username FROM test WHERE username='".$username."");

    while($row = mysqli_fetch_array($result))

    {

    echo $row['username'];

    }

    mysqli_close($con);

    ?>

    This is the value that is returned when I run my program in Construct 2 over a public hosted server:

    <img src="http://img27.imageshack.us/img27/8505/546i.png" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I got it- ill upload solution in a few.

  • I got it- ill upload solution in a few.

    Could you post the solution please?

    I have the same problem :(

  • > I got it- ill upload solution in a few.

    Could you post the solution please?

    I have the same problem :(

    Solution for me was the following:

    I just had a typo writing the name of the table from which I had to retrieve data. If you try to call an unexisting table, you'll have </ br> as result.

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