The update works fine on localhost, but not in this live server. I could even see the console transporting the header but it doesnt reflect in the database. I have another php page with INSERT commands, and it works, so I dont know why this one doesnt.
It turns out that all my update and even delete queries across all pages doesnt work. What could be the problem?
It says something about datetime, even if I dont mess with touching the datetime at all
Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value:
this is updatepeople.php
include_once("../connections/db.inc.php");
if(isset($_POST['id'])) {
$value = $_POST['value'];
$column = $_POST['column'];
$id = $_POST['id'];
$sql = "UPDATE people SET $column = :value WHERE md5(personId) = :id OR personId =:id LIMIT 1";
$stmt = $db->prepare($sql);
$stmt->bindParam(":value", $value);
$stmt->bindParam(":id", $id);
if($stmt->execute()){
echo "Yup";
}
else {
echo "fail";
}
}
html
<td><div contenteditable="true" onBlur="updateValue(this, 'lName', '<?php echo $id;?>')" ><?php echo $lName; ?></div></td>
jquery
function updateValue(element,column,id) { var result = confirm("Are you sure you want to update value?"); if (result) { var value = element.innerText; $.ajax({ url:'updatepeople.php', type: 'post', data:{ value: value, column: column, id: id }, success: function(php_result) { console.log(php_result); } }) } }
my table structure is this
I tried this setting PDO::PARAM_INT for the $id bind. The error message disappeared, but no update happens in the database.
EDIT: alright it worked. Setting PDO::PARAM_INT for the id variable worked, it only needed a little time to update the changes.