Hi all , I have searched and tryed to fix my problem but without luck , it whould be nice if someone can give me a hand .
Here is my function for interact with mysql :
this functions does update the players score , it does adds the new score to the old one. What I need to change is on this it should only replace if the new score is higher then the old. And not calculate together just update new score if higher.
My second question is how can I run this function in php ?
Thank you
Here is my function for interact with mysql :
Code:
function IncreasePlayerScore( $sid, $player ) {
// Update information about the player in database
$tbl = SERVER_TABLE_NAME.$sid;
$kia = -intval($player['kia']) / 4;
$roe = -intval($player['roe']);
$cmd = "INSERT INTO `$tbl` (`name`, `score`, `goal`, `leader`, `enemy`, `kia`, `roe`) VALUES('"
.mysql_real_escape_string($player['name'])."', '".$player['score']."', '".$player['goal']."', '".$player['leader']."', '".$player['enemy']."', '$kia', '$roe'"
.") ON DUPLICATE KEY UPDATE `score`=score+'".$player['score']."', `goal`=goal+'".$player['goal']."', `leader`=leader+'".$player['leader']
."', `enemy`=enemy+'".$player['enemy']."', `kia`=kia+'$kia', `roe`=roe+'$roe'"
.";";
if( !mysql_query($cmd) ) echo "Error updating player info: ".mysql_error()."<br />$cmd";
}
My second question is how can I run this function in php ?
Thank you