Game Development Community

Getting Problem with Online Scoring

by Playware · in Torque Game Builder · 12/17/2008 (12:32 am) · 2 replies

Hi,



I am working on project in which I have to save my score from TGB 1.3 to MySQL Database. Just like you given sorce code for Go Beryllium. But my scpre are not saved in database. what could be the problem. For this I have tcpScripts,cs. In this I have

function TCPSubmitScore(%firstname,%awardAcheived)
{
%obj = new TCPObject(TCPScoreSender);
%obj.firstname = %firstname;
%obj.awardAcheived = %awardAcheived;
}



function TCPScoreSender::onConnected(%this)
{
%data = "FirstName=" @ %this.firstname @ "&AwardAcheived=" @ %this.awardAcheived;


%httpCmd="POST /MyFolderName/submit.php HTTP/1.1\nHost: www.name.byethost.com:80\nUser-Agent: Torque/1.0 \nAccept: */*\nContent-Length: "@ strlen(%data) @"\nContent-Type: application/x-www-form-urlencoded;\n\n" @ %data;
%this.send(%httpCmd @ " \r\n");
}

function TCPScoreSender::onLine(%this, %line)
{

if(firstWord(%line) $= "Score") // returned from php file - indicates success
{
$successfulSend = true;
echo("--------------- successfully send ---------------------");
}

if(firstword(%line) $= "RETURN:")
{
echo(restwords(%line));
warn("Disconnecting");
%this.disconnect();
}
}



Now I am calling TCPSubmitScore("David","Gold"); but no success result is coming from onLine().


I think my php is not calling, bec I am showing echo message in PHP. and its not coming.But my php file exists in myFolder. For your ref I am attaching php file also.
Once I call TCPSubmitScore(), I am getting these following in console........



=>TCPSubmitScore("David","Gold");


++++++++++++++ %httpCmd = POST /MyFolderName/submit.php HTTP/1.1
Host: www.name.byethost.com:80
User-Agent: Torque/1.0
Accept: */*
Content-Length: 205
Content-Type: application/x-www-form-urlencoded;FirstName=David&AwardAcheived=Gold
--------------- in onLine() %line = HTTP/1.0 302 Moved Temporarily
--------------- in onLine() %line = Date: Wed, 17 Dec 2008 07:45:25 GMT
--------------- in onLine() %line = Server: Apache
--------------- in onLine() %line = Location: http://byet.org/web/index.html
--------------- in onLine() %line = Cache-Control: max-age=0
--------------- in onLine() %line = Expires: Wed, 17 Dec 2008 07:45:25 GMT
--------------- in onLine() %line = Vary: Accept-Encoding
--------------- in onLine() %line = Content-Length: 10--------------- in onLine() %line = Content-Type: text/html; charset=iso-8859-1
--------------- in onLine() %line = X-Cache: MISS from demil1.byetcluster.com
--------------- in onLine() %line = X-Cache-Lookup: MISS from demil1.byetcluster.com:80
--------------- in onLine() %line = Via: 1.1 demil1.byetcluster.com:80 (squid/2.7.STABLE5)
--------------- in onLine() %line = Connection: close
--------------- in onLine() %line =
--------------- in onLine() %line =
--------------- in onLine() %line =
--------------- in onLine() %line = 302 Found
--------------- in onLine() %line =
--------------- in onLine() %line =

Found


--------------- in onLine() %line =

The document has moved here.


--------------- in onLine() %line =



So, Whats happening here?


I needed your help very badly.

#1
12/17/2008 (12:33 am)
And My submit.php content is...............





$fname = $_POST['FirstName'];
$AwardAcheived = $_POST['AwardAcheived'];

echo("-------------------- in submit php ----------------");
echo($fname);
echo("-------------------- in submit php ----------------");


$service = "sql8914.byethost.com";
$username = "David";
$password = "******";
$database = "DavidDB";

mysql_connect($service, $username, $password);
@mysql_select_db($database) or die( "++++++++++++++++++ Unable to select database ++++++++++++++");


// insert new score
$query="INSERT INTO StudentDetails
VALUES ('$fname','$AwardAcheived')";
$result=mysql_query($query);
if($result)
echo("Score submitted! FirstName: $fname");
else
echo("--------- Sorry -------- Score couldn't submitt!");

?>
#2
12/17/2008 (12:34 am)
Anybody has any Idea? Pls, help me.