Reduan Kurtaj Reduan Kurtaj - 2 months ago 24
Ajax Question

Ajax POST 500 internal error

I have a problem with my ajax call. It gives me the error shown below. I have looked around here and at Google to find the problem, but I did not find a solution. So, I hope someone can the mistake I've made.

console.log
shows that the variable is working fine. So I know 100% the error is in the ajax call.


jquery-2.1.1.min.js:4 POST http://localhost:8888 500 (Internal Server Error)
send
@ jquery-2.1.1.min.js:4
ajax @ jquery-2.1.1.min.js:4
(anonymous function) @ script.js:61


if (isConfirm) {
var aanhef = $('select[name="aanhef"]').val();
var username = $('input[name="username"]').val();
var achternaam = $('input[name="achternaam"]').val();
var adres = $('input[name="adres"]').val();
var plaats = $('input[name="plaats"]').val();
var postcode = $('input[name="postcode"]').val();
var email = $('input[name="email"]').val();
var tell = $('input[name="tell"]').val();
var where = $('input[name="hidden_email"]').val();
}

console.log(aanhef + ' ' + username + ' ' + achternaam + ' ' + adres + ' ' + plaats + ' ' + postcode + ' ' + email + ' ' + tell + ' ' + where);

$.ajax({
type: 'post',
url: 'config/save_profiel.php',
data: { 'aanhef': aanhef, 'naam': username, 'achternaam': achternaam, 'adres': adres, 'plaats': plaats, 'postcode': postcode, 'email': email, 'tell': tell, 'where': where}
});



$aanhef = mysqli_real_escape_spring($conn,$_POST['aanhef']);
$name = mysqli_real_escape_spring($conn,$_POST['username']);
$achternaam = mysqli_real_escape_spring($conn,$_POST['achternaam']);
$adres = mysqli_real_escape_spring($conn,$_POST['adres']);
$plaats = mysqli_real_escape_spring($conn,$_POST['plaats']);
$postcode = mysqli_real_escape_spring($conn,$_POST['postcode']);
$email = mysqli_real_escape_spring($conn,$_POST['email']);
$tell = mysqli_real_escape_spring($conn,$_POST['tell']);
$where = mysqli_real_escape_spring($conn,$_POST['where']);
$first = '1';



$updateUser = "UPDATE users SET aanhef='$aanhef', name='$name', last_name='$achternaam', telefoon='$tell', adres='$adres', plaats='$plaats', postcode='$postcode', first_login='$first' WHERE email='$where'";

if ($updateUser) {
mysqli_query($conn,$updateUser) or die (mysqli_error($conn));
}

Answer

As I noted in a comment above, HTTP 500 indicates a generic server-side error. Anytime you see it your first step should be to check your logs.

You did that, and you found the following message:

PHP Fatal error: Call to undefined function mysqli_real_escape_spring() in /Applications/MAMP/htdocs/save_profiel.php

That seems to point the way pretty clearly: You've misspelled mysqli_real_escape_string.