我一直在尝试插入数据库但是当我添加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);
?>