When I try to add , this error is displaying : An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND ACTIVE_STATUS = 'Yes'' at line 1
SQL syntax error in server event
-
- User
- Posts: 8
if (strlen($chkl_name) > 0) {
$chklCount = count(explode(',', $chkl_name));
for($i = 0; $i < $chklCount; $i++) {
$checklist_no = $arr_chkl_no[$i];
$selectDetails = "SELECT REF_DOC_NO,CHECKLIST_NO FROM tech_wrtg_checklist_ref_doc WHERE CHECKLIST_NO = $checklist_no AND ACTIVE_STATUS = 'Yes'";
//echo $checklist_no;
$rswrk = ExecuteQuery($selectDetails);
while ($row = $rswrk->fetchAssociative()) {
$sno = ExecuteScalar("select MAX(SNO) from tech_wrtg_checklist_details where PSLNO = '$pslno'");
$sno = $sno + 1;
ExecuteStatement("INSERT tech_wrtg_checklist_details (PSLNO,SNO,REF_DOC_NO,CHECKLIST_NO) VALUES ('".$pslno."','".$sno."','".$row['REF_DOC_NO']."', '".$row['CHECKLIST_NO']."')");
}
}
ExecuteStatement("UPDATE tech_wrtg_input SET CHKL_TYPE = '$chkl_name' WHERE SLNO = '$pslno'");
}
The above code is present in grid inserting event, but the syntax error is displaying
-
- User
- Posts: 9384
dheeksha2511 wrote:
$selectDetails = "SELECT REF_DOC_NO,CHECKLIST_NO FROM tech_wrtg_checklist_ref_doc WHERE CHECKLIST_NO = $checklist_no AND ACTIVE_STATUS = 'Yes'";
You should check the data type of the field CHECKLIST_NO and ACTIVE_STATUS, make sure the values in the SQL are correct. For example, if CHECKLIST_NO is of string type, you should quote the value.
You better var_dump($selectDetails)
and check/test your SQL first.