0

I have a question regarding this statement. its showing an error like this

Warning: oci_execute(): ORA-00984: column not allowed here in C:\xampp\htdocs\WeltesInformationCenter\Component_request\save.php on line 41

and my code is like this,

 $componentHistoryParse = oci_parse($conn, "INSERT INTO HISTORY_COMPONENT_CUTTING 
                    (BASE_PLATE, REQUESTER, REQUEST_DATE, QTY_PROPOSED, REMARKS, PROJECT_NAME, THICKNESS, REQ_STATUS)
             VALUES (:bp, $username, SYSDATE, :qt ,:rm , :pj, :tc, 'PENDING')");

oci_bind_by_name($componentHistoryParse, ":bp", $_POST['baseplate']);
oci_bind_by_name($componentHistoryParse, ":qt", $_POST['quantityToCut']);
oci_bind_by_name($componentHistoryParse, ":rm", $_POST['text_remarks']);
oci_bind_by_name($componentHistoryParse, ":pj", $_POST['projectName']);
oci_bind_by_name($componentHistoryParse, ":tc", $_POST['thickness']);

$componentHistoryRes = oci_execute($componentHistoryParse);

if($componentHistoryRes){
   oci_commit($conn);
} else {
   oci_rollback($conn);
}

and the column names in the table are

BASE_PLATE VARCHAR2, NAME VARCHAR2, REQUESTER VARCHAR2, REQUEST_DATE DATE, REMARKS VARCHAR2, PROJECT_NAME VARCHAR2, PROJECT_NO VARCHAR2, THICKNESS NUMBER, REQ_STATUS VARCHAR2, QTY_PROPOSED NUMBER

2 Answers 2

1

Try:

 $componentHistoryParse = oci_parse($conn, "INSERT INTO HISTORY_COMPONENT_CUTTING 
                (BASE_PLATE, REQUESTER, REQUEST_DATE, QTY_PROPOSED, REMARKS, PROJECT_NAME, THICKNESS, REQ_STATUS)
         VALUES (:bp, '$username', SYSDATE, :qt ,:rm , :pj, :tc, 'PENDING')");

i.e. quotes around $username

Sign up to request clarification or add additional context in comments.

Comments

1

$username expands to just the value without any quotes, which then the database sees as a column name, not a string.

You could fix it by quoting username as '$username' but - better to avoid SQL injection - you should really put username in a parameter as you do the other values.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.