I am adding below code to functions.php
file in WordPress and getting syntax error, unexpected ' ' (T_STRING)
error.
add_action('wp_ajax_nopriv_save_order_data', 'save_order_data');
add_action('wp_ajax_save_order_data', 'save_order_data');
function save_order_data() {
global $wpdb;
$total_amt = $_POST['amount'];
$stmt = $wpdb->query("INSERT INTO order_master (payment_amt) VALUES ($total_amt)" );
$result = $wpdb->query($wpdb->prepare($stmt));
if($result)
{
$res="Data Inserted Successfully:";
echo json_encode($res);
}
else {
$error="Not Inserted,Some Probelm occur.";
echo json_encode($error);
}
}
Getting error on this line:
$stmt = $wpdb->query("INSERT INTO order_master (payment_amt) VALUES ($total_amt)" );