So many question with this title but none of them able to solve my problem and I dont know WTH? This is a simple code php adding data to a table
global $connPDO;
ini_set('date.timezone', 'Asia/Karachi');
$date = date('Y-m-d H:i:s');
$sql = "INSERT INTO `pqa` VALUES (null, :ProId, :ProQuestion, null, '$date', null)";
$queryInsert = $connPDO->prepare($sql);
try {
//Post contain $_POST["ProId"], $_POST["ProQuestion"];
$querySuccess = $queryInsert->execute($_POST);
echo $querySuccess;
}
catch(Exception $e) {
echo '<h1>An error has ocurred.</h1><pre>', $e->getMessage() ,'</pre>';
}
Catch block is not executing but giving error.
var data = {
"action" : "SaveProjectNewQuestion",
"ProId" : 1,
"ProQuestion" : $jqueryLib("#NewQuestion").val()
};
$jqueryLib.ajax({
url : "ESP.php",
type : "POST",
data : data,
success : function(data, textStatus, XMLHttpRequest) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
Amazingly success log showing this warning and no data has inserted also.
( ! ) Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\wamp\www\ESP\ESP.php on line 5621............................