martinjamesroberts Posted February 4, 2011 Share Posted February 4, 2011 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"; } ?> Quote Link to comment Share on other sites More sharing options...
litebearer Posted February 4, 2011 Share Posted February 4, 2011 To 'overwrite' a specific record use UPDATE and WHERE somedatabasefield = '$somevariable' Quote Link to comment Share on other sites More sharing options...
martinjamesroberts Posted February 4, 2011 Author Share Posted February 4, 2011 Yes like this ? $query = "UPDATE entries SET entry_name=`$entry` WHERE name=$pseudo"; Thing is, I know next to nothing about php, how do I call $query ? or can I put it into $envoie ? Quote Link to comment Share on other sites More sharing options...
litebearer Posted February 4, 2011 Share Posted February 4, 2011 1. yes 2. yes it is a query and you then need to 'execute' the query Quote Link to comment Share on other sites More sharing options...
martinjamesroberts Posted February 4, 2011 Author Share Posted February 4, 2011 Thanks, how do I do that ? Is it like actionscript and I just run $query or do I have to feed it variables ? Quote Link to comment Share on other sites More sharing options...
martinjamesroberts Posted February 4, 2011 Author Share Posted February 4, 2011 or is it like this mysql_query($query); Quote Link to comment Share on other sites More sharing options...
martinjamesroberts Posted February 4, 2011 Author Share Posted February 4, 2011 <?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"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.