Hi,
I have 2 PHP files that I am trying to understand. They are part of a Flash game that I have. The Flash game allows you to submit a high score, and also builds a high score table using data stored in a database.
This first script is from the Score.php file.
<?php
include "includes/connection.php";
include "includes/function.php";
$raw_xml = file_get_contents("php://input");
$TheArrNickName = GetTagValue("PlayerName",$raw_xml);
$str_nickname = $TheArrNickName[0];
$TheArrEmailId = GetTagValue("EmailId",$raw_xml);
$str_emailid = $TheArrEmailId[0];
$TheArrScore = GetTagValue("Score",$raw_xml);
$str_score = $TheArrScore[0];
$date = getDate();
$strdate = $date['year']."/".$date['mon']."/".$date['mday']." ".$date['hours'].":".$date['minutes'].":".$date['seconds'];
$sqlInsert1 = "Insert into cargame (playerName,playerEmail,score,entryDate) values ('$str_nickname','$str_emailid',$str_score,'$strdate') ";
ExecuteSql($sqlInsert1);
$sqlInsert2 = "Insert into game_period (playerName,playerEmail,score,entryDate) values ('$str_nickname','$str_emailid',$str_score,'$strdate') ";
ExecuteSql($sqlInsert2);
echo ('<?xml version="1.0" encoding="ISO-8859-1" ?>');
echo("<ScoreReply>");
echo("<StatusDesc>Score has been updated Successfully</StatusDesc>");
echo("</ScoreReply>");
?>
The second script is from the leaderboard.php file.
<?php
include "includes/connection.php";
include "includes/function.php";
$raw_xml = file_get_contents("php://input");
$TheArrRequest = GetTagValue("Request",$raw_xml);
$str_Request = $TheArrRequest[0];
$date = getDate();
$Seldate = $date['year']."/".$date['mon']."/01";
$sqlselect = "SELECT playername,playerEmail,score FROM cargame order by score desc ";
ExecuteSql($sqlselect,"objrs");
if (mysql_num_rows($objrs)<=100)
$rowcount = mysql_num_rows($objrs);
else
$rowcount =100;
echo ('<?xml version="1.0" encoding="ISO-8859-1" ?>');
echo("<LeaderBoard>");
for($i=0;$i<$rowcount;$i++)
{
$row = mysql_fetch_row($objrs);
$strPlayerName = $row[0];
$strPlayerEmailId = $row[1];
$strScore = $row[2];
echo("<HighScore>");
echo("<PlayerName>" . $strPlayerName ."</PlayerName>");
echo("<PlayerEmailId>" . $strPlayerEmailId ."</PlayerEmailId>");
echo("<Score>". $strScore ."</Score>");
echo("</HighScore>");
}
echo("</LeaderBoard>");
?>
Can a kind person tell me in basic terms (I have nearly no PHP experience) what the 2 scripts are doing? and how is the XML used exactly?
Regards,
adsmithy