Intro: I am doing a serverside datatables library using ajax.
Error: It looks like my print_r($stmt) is returning Object. This first error I believe is causing my other errors such as "uncaught error: call to a member function fetch_assoc() on null".
Additionally, I do not think print_r($result) is showing any details.
Ajax Code:
<script type="text/javascript">
$(document).on('click','.edit_btn',function (){
var id = $(this).attr("id").match(/\d+/)[0];
var edit_id = $('#example').DataTable().row( id ).data();
var edit_id = edit_id[0];
$.ajax({
type:'POST',
url: 'form.php',
datatype: "json",
data: { edit_id : edit_id },
success: function(result) {
//alert(edit_id);
alert(result);
$("#edit_id").val(edit_id);
} //success func
}); //ajax
}); //end ready
</script>
Form.php:
$conn=mysqli_connect($host,$user,$pass,$db);
$stmt = $conn->prepare("SELECT * FROM `employees` WHERE `id` = ?");
$stmt->bind_param("i", $_POST['edit_id']);
$stmt->execute();
print_r($stmt);
$result = mysqli_query($conn, $stmt);
print_r($result);
$row = $result->fetch_assoc();
echo $row;