I have a small problem, which is that when I add my prepared statement into the PHP file, the Ajax stops working and gives me a 500- error, but when I remove the statement, it works like a charm.
This is my PHP file:
<?php
include ('db_connect.php');
include ('functions.php');
$datad = $_POST['superstr'];
$id = 1;
$stmt = $mysqli->prepare("UPDATE `song` SET `lyrtext`=? WHERE `id`=?");
$stmt->bind_param("si", $datad, $id);
$status = $stmt->execute();
echo $datad;
?>
and my Ajax looks like this:
$.ajax({
url: 'includes/sendlyrics.php',
type: 'POST',
data: {superstr: 'pelle'},
success: function(data) {
//called when successful
var hello = data;
//prompt(data);
console.log("The data is:");
console.log(data);
console.log("The variable which should keep the data has this content:");
console.log(hello);
},
error: function(e) {
//called when there is an error
console.log(e.message);
prompt(e.message);
//alert(e.message);
}
});
What's the problem?