AJAX request not returning right value

Get help using Construct 2

Post » Sun Oct 20, 2013 5:44 pm

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:



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:

GameThirsty2013-10-20 17:45:10
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Sun Oct 20, 2013 6:24 pm

I got it- ill upload solution in a few.
B
17
S
6
Posts: 348
Reputation: 2,608

Post » Mon Oct 21, 2013 3:21 pm

[QUOTE=GameThirsty] I got it- ill upload solution in a few.[/QUOTE]

Could you post the solution please?
I have the same problem :(secretcastle872013-10-21 15:46:38
B
3
Posts: 2
Reputation: 179

Post » Wed Oct 23, 2013 11:19 am

[QUOTE=secretcastle87] [QUOTE=GameThirsty] I got it- ill upload solution in a few.[/QUOTE]

Could you post the solution please?
I have the same problem :([/QUOTE]

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.
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: evillair, Yahoo [Bot] and 6 guests