What are these scripts doing?

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

[quote=adsmithy;2364982]Thanks for that, really helpful.

What is confusing me is the XML part. Is an XML file being created or is the SWF creating the XML and then sending it to the PHP file?

This is a link to my other thread, with the actionscript code:

An xml response is being created and sent back to flash via post. Flash will parse this because it is a language it understands. XML is a medium of which the PHP, or server side code, could emulate inorder to send data to the Flash for breakdown.

Right so the XML response is being created by the PHP script and sent back to Flash?

How does Flash send data to the PHP script in the first place?

Thanks for the help BTW :beer2: