My code works great except for the "userName" for some reason sending a string through JSON will not post to table, it sends nothing.
Can anyone see what the problem is?
jquery
lowestScoreId = 1;
userPoints = 50;
userName = "ted";
$.getJSON("functions/updateHighScores.php", {lowestScoreId: lowestScoreId, userPoints: userPoints, userName: userName}, function(data) {
$('#notes').text(data.userName); //for testing
});
php
lowestScoreId = json_decode($_GET['lowestScoreId']);
$userName = json_decode($_GET['userName']);
$userPoints = json_decode($_GET['userPoints']);
include 'config.php';
$currentTime = time();
mysql_query("UPDATE highScores
SET `name` = '$userName',
`score` = '$userPoints',
`date` = '$currentTime'
WHERE id='$lowestScoreId'");
echo json_encode(array("userName" => $userName)); // for testing
$obj.$obj=json_decode($_GET['jsonObj'])and the rest of the values taken from the JSON object. Another thing... you're not sanitizing your inputs and feeding that straight into your MySQL database.