PHP SQL代码ON DUPLICATE KEY无法正常工作

时间:2014-04-15 15:44:31

标签: php mysql sql

我一直在尝试插入数据库但是当我添加ON DUPLICATE KEY UPDATE code=code时它不会插入任何内容,无论是否有重复的条目,否则代码全部正常工作。有谁知道它有什么问题?

    <?php
session_start();
$con=mysqli_connect("HOST","USERNAME","PASSWORD","DB_NAME");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$user=$_SESSION['user']['username'];
mysqli_query($con,"INSERT INTO achievements (username, secretgame, code)
VALUES ('$user', 'You Have found a Secret Game',40) ON DUPLICATE KEY UPDATE code=code");


mysqli_close($con);
?>  

0 个答案:

没有答案