I'm sending a AJAX Call to a seperate file for a MySQL INSERT query. Everything works perfect until someone uses a quote ('); MySQL throws a syntax error even though before the query I use addslashes and mysqli_real_escape_string. This problem occurs in Safari but doesn't in Chrome.
Anyone know more about this specific issue and how to fix it?
jQuery Ajax
$('body').on('keyup', '.dbDriven', function() {
var val = $(this).val();
$.ajax({url: 'dbUpdate.inc.php',type: "GET",data:
{
val: val
}
}).done(function ( data ) {
console.log(data);
});
});
dbUpdate.inc.php
$_GET['val'] = addslashes($_GET['val']);
$value = mysqli_real_escape_string($_GET['val']);
mysqli_query("UPDATE table SET column = `".$value."` WHERE id = '1'") or die(mysql_error());