我对此声明有疑问。它显示如下错误
Warning: oci_execute(): ORA-00984: column not allowed here in C:\xampp\htdocs\WeltesInformationCenter\Component_request\save.php on line 41
我的代码是这样的,
$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);
}
并且表中的列名是
BASE_PLATE VARCHAR2, NAME VARCHAR2, REQUESTER VARCHAR2, REQUEST_DATE DATE, 备注VARCHAR2, PROJECT_NAME VARCHAR2, PROJECT_NO VARCHAR2, 厚度数, REQ_STATUS VARCHAR2, QTY_PROPOSED NUMBER
答案 0 :(得分:1)
尝试:
$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')");
即。引号$username
答案 1 :(得分:1)
$username
扩展为没有任何引号的值,然后数据库将其视为列名,而不是字符串。
您可以通过引用用户名'$username'
来修复它,但是 - 更好地避免SQL注入 - 您应该在执行其他值时将用户名放在参数中。