Reputation: 145
Chrome console error: POST http://******************** 500 (Internal Server Error)
JS
$.ajax({
method: "POST",
url:"ajax.php",
data: {
x: x,
y: y
},
success:function(data){...}
});
PHP
<?php
date_default_timezone_set('Europe/Madrid');
$link = mysql_connect("*******", "*******", "******");
mysql_select_db("******") or die ("no database");
$name = $_POST['x'];
$score = $_POST['y'];
// Get the current date
$current_date = date('d-m-Y H:i:s');
$sqlCommand = "INSERT INTO hungry_bird (date_played, name, score)
VALUES('$current_date ', '$name', '$score')";
$results = mysql_query($sqlCommand) or die (mysql_error());
mysql_close($link);
?>
Any idea what could be the problem? Thanks.
Upvotes: -1
Views: 61
Reputation: 1189
$link = mysqli_connect("*******", "*******", "******");
mysqli_select_db($link, "******") or die ("no database");
$name = $_POST['x'];
$score = $_POST['y'];
$sqlCommand = "INSERT INTO hungry_bird (date_played, name, score)
VALUES('CURDATE()', '$name', '$score')";
$results = mysqli_query($link, $sqlCommand) or die (mysqli_error($link));
mysqli_close($link);
Upvotes: 1