Get data from database

Hi all, Been trying to fix this all day and given in for now so thought I would ask for help.

I have a unity project with a login form. I have managed to get it to login / register a new user, what i’m having problems with now is retrieving that data.

This is the code i’m trying to use.

static var myScore : int = 0;
static var test;
var received_data = [];


function Start(){
var logform = new WWWForm();
	logform.AddField("username" , 'Pete');
	var logw = new WWW("www.mysite.co.uk/score.php", logform);
		yield logw;
}

function doLoad(){

	var url = "www.yourtechnerds.co.uk/superpea/score.php";
	var w = WWW(url);
	yield w;
	received_data = w.data.Split("/"[0]);
	test = (received_data[0]);
	yield WaitForEndOfFrame;
}

So essentially check the username and return the values from the PHP mysql.

I have split the data with “/”

On my php Side i’m using

<?PHP
$con=mysqli_connect("localhost","dbname","password","dbuser");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$username = mysql_real_escape_string($_POST['username']);//takes the username inputted from the wwwform.

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

while($row = mysqli_fetch_array($result))
  {
  echo $row['user'] ."/" . $row['pass']."/"  ;

  }

mysqli_close($con);
?>

If I drop the Where Clause I can return all records from the database and if I drop the function Start() code from unity I can see the records perfectly! I just can’t seem to get it to work based on a username!

Hope this makes sense!

Thanks for your time.

Pete

You try to get password from post:

$password = mysql_real_escape_string($_POST['password']);

But I didn’t see such field in the Start() method.

Thanks for the guidance, managed to fix it by merging the 2 functions in Unity.

Pete