SQL syntax error in server event

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
dheeksha2511
User
Posts: 8

SQL syntax error in server event

Post by dheeksha2511 »

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


arbei
User
Posts: 9384

Post by arbei »

dheeksha2511 wrote:

You have an error in your SQL syntax ... near 'AND ACTIVE_STATUS = 'Yes'' at line 1

Double check your code in your server event, make sure the SQL is correct.

You should enable Debug and check the complete errors with the complete SQL in the log file.


dheeksha2511
User
Posts: 8

Post by dheeksha2511 »

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


arbei
User
Posts: 9384

Post by arbei »

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.


Post Reply