I am trying to pass some values to a mysql table but I do something wrong. I call this function from somewhere:
function updatebets(postid, bet, betamount){
alert(postid + " " + bet + " " + betamount);
$.ajax({
type: 'POST',
url: 'current.php',
data: {bankpostid: postid, bankbet: bet, bankbetamount: betamount},
success: function(){
alert('works');
},
error: function(){
alert('something went wrong');
}
});
}
This is the current.php page:
<?php
global $current_user, $wpdb;
$uid = $current_user->ID;
$postid = $_POST['bankpostid'];
$bet = $_POST['bankbet'];
$betamount = $_POST['bankbetamount'];
$sql = "INSERT INTO bets (postid, uid, bet, betamount) VALUES ('$postid', '$uid', '$bet' , '$betamount')";
$wpdb->query($sql);
?>
The fields "postid, uid, bet, betamount" are the name fields of the table I want to update. I get the error 'something went wrong'. I am working with wordpress, the page current.php is in the theme folder.