$sql = "SET @tag_name = '$tag_value',
@tag_link = '$tag_link',
@user_value = '$user_value';
INSERT INTO urls_unis
(tag_name, tag_link, user_data)
VALUES
(@tag_name, @tag_link, @user_value)
ON DUPLICATE KEY UPDATE
tag_name = @tag_name,
tag_link = @tag_link,
user_data = @user_value;
";
if(mysqli_query($link, $sql)){
echo "Records inserted successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
}
The above code is returning this:
ERROR: Could not able to execute
SET @tag_name = 'View history', @tag_link = 'zNIL', @user_value = '/w/index.php?title=Non-volatile_random-access_memory&action=history'; INSERT INTO urls_unis (tag_name, tag_link, user_data) VALUES (@tag_name, @tag_link, @user_value) ON DUPLICATE KEY UPDATE tag_name = @tag_name, tag_link = @tag_link, user_data = @user_value; .You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO urls_unis (tag_name, tag_link, user_data) VALUES (@tag_name,' at line 4
When I copy and paste the mysql query to phpmyadmin to execute it, it works fine. No errors were returned.
How come, and how can I solve this?