Jump to content

Overwrite SQL entry


martinjamesroberts

Recommended Posts

Hello there,

 

I have some code here which sends a number of variables from flash to SQL...

 

I would simply like to add the functionality to overwrite records which have the same 'name' or 'pseudo'... can anyone help me please ? Thanks in advance Martin

 

<?php

$pseudo=$_POST['var1'];
$score=$_POST['var2'];
$table = $_POST['tab'];

$dategame = $_POST['tempjoueur'];
//$micro = microtime();
//$dategame = time()."".substr($micro, 2, 6);

$_COOKIE['User'] = $_SERVER['REMOTE_ADDR'];
$envoie = InsertDatas($table, "name, score, dategame", "'".$pseudo."','".$score."','".$dategame."'");
if ($envoie) {
print_r("OK, $pseudo, $score, $dategame,$ipclient");
}
else { echo "BAD, $pseudo, $score, $dategame,$ipclient"; }
?>

Link to comment
https://forums.phpfreaks.com/topic/226666-overwrite-sql-entry/
Share on other sites

<?php

$pseudo=$_POST['var1'];
$score=$_POST['var2'];
$table = $_POST['tab'];

$dategame = $_POST['tempjoueur'];

$query = "UPDATE entries SET score=`$score` WHERE name=$pseudo";
mysql_query($query);

$_COOKIE['User'] = $_SERVER['REMOTE_ADDR'];
$envoie = InsertDatas($table, "name, score, dategame", "'".$pseudo."','".$score."','".$dategame."'");
if ($envoie) {
print_r("OK, $pseudo, $score, $dategame,$ipclient");
}
else { echo "BAD, $pseudo, $score, $dategame,$ipclient"; }

?>

Link to comment
https://forums.phpfreaks.com/topic/226666-overwrite-sql-entry/#findComment-1169799
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.