[HELP]Inserting data into a MySQL table - Checking for duplicates
Hi,
I've made a flash game with a highscore table. I used PHP and MySQL for this. The only thing is that if you refresh a certain page it makes another entry in the database. I want it to check to see whether there is already a entry with that name and score. Here's my code:
<?php
// set your infomation.
$dbhost='I bet';
$dbusername='you would';
$dbuserpass='like to know';
$dbname='this you hacker!';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
if (!mysql_select_db($dbname)) die(mysql_error());
$score = secretinfo;
$name = notforyoureyes;
$query = "INSERT INTO highscore (gameid, name, score) VALUES('$gameid','$name','$score')";
mysql_query($query) or die(mysql_error());
echo "Highscore inserted successfully, view highscore table <a href='highscore.php?game=$gameid' target'_self'>here.</a>";
?>
Rep will be given to person modifies this code for me :]
Hi,
I've made a flash game with a highscore table. I used PHP and MySQL for this. The only thing is that if you refresh a certain page it makes another entry in the database. I want it to check to see whether there is already a entry with that name and score. Here's my code:
<?php
// set your infomation.
$dbhost='I bet';
$dbusername='you would';
$dbuserpass='like to know';
$dbname='this you hacker!';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
if (!mysql_select_db($dbname)) die(mysql_error());
$score = secretinfo;
$name = notforyoureyes;
$query = "INSERT INTO highscore (gameid, name, score) VALUES('$gameid','$name','$score')";
mysql_query($query) or die(mysql_error());
echo "Highscore inserted successfully, view highscore table <a href='highscore.php?game=$gameid' target'_self'>here.</a>";
?>
Rep will be given to person modifies this code for me :]






