我正在一個有4列的表上工作,第一個是一個叫做id的自動遞增整數。PHP Mysqli插入一行到auto_increment列的表
如果即將使用mysqli準備好的語句插入到此表中,我仍然遇到插入工作的查詢時遇到問題。使用PHPmyAdmin它告訴我給它NULL。香港專業教育學院嘗試這樣:
$query = "INSERT INTO tbl (id, col2, col3, col4) VALUES ('NULL', ?, ?, ?)";
$stmt -> bind_param("ssi", $col2, $col3, $col4)
這
$query = "INSERT INTO tbl (id, col2, col3, col4) VALUES (NULL, ?, ?, ?)";
$stmt -> bind_param("ssi", $col2, $col3, $col4)
,並只給bind_param 3個參數(最後3)。這些都沒有工作。我也試過這個:
$null = NULL;
$query = "INSERT INTO tbl (id, col2, col3, col4) VALUES (?, ?, ?, ?)";
$stmt -> bind_param("issi", $null, $col2, $col3, $col4);
沒有這些工作。是否有插入這種類型的表的標準方式?
你是否也想明確插入自動遞增字段? – Sarfraz 2010-02-09 06:27:31