Scenario: I'm trying to incorporate it so that when you click this button, it adds 1 to a value in the database.
I've read so many articles about AJAX today but no solution.
P.S. The query works fine directly from the command line.
This is what I've written so far but I think I'm completely missing something.
game.php
<script>
function logCountAdd(){
var request = $.ajax({
type: "GET",
url: "logCountAdd.php"
});
request.done(function(msg ) {
alert('Success');
return;
});
request.fail(function(jqXHR, textStatus) {
alert("Request failed: " + textStatus);
});
};
</script>
</head>
<body>
<button type="button" onclick="logCountAdd()">Gather Resources</button>
logCountAdd.php
<?php
$connection = mysqli_connect("localhost","root","","users");
if (mysqli_connect_errno())
{
echo 'NOT_OK';
}
mysqli_query($connection, "UPDATE uc_users
SET logCount = logCount + 1
WHERE user_name='Gregory'";)
mysqli_close($connection);
echo 'OK';
?>
Problem: After I click the button, the value in the database does not change.
The Error Code: GET logCountAdd.php 500 (Internal Server Error)jquery-1.11.2.min.js:4 m.ajaxTransport.sendjquery-1.11.2.min.js:4 m.extend.ajaxgame.php:7 logCountAddgame.php:22 onclick
First question asked on here, sorry guys!