4
我試圖插入新記錄插入數據庫時有問題。我認爲問題在於位域。當我給你的價值真的,我得到這個錯誤:如何將數據插入位數據類型的字段?
Failed: Array ([0] => Array ([0] => 22018 [SQLSTATE] => 22018 [1]
=> 245 [code] => 245 [2] => [Microsoft][SQL Server Native Client 10.0]
[SQL Server]Conversion failed when converting the varchar value ' 1 '
to data type bit. [message] => [Microsoft][SQL Server Native Client 10.0]
[SQL Server]Conversion failed when converting the varchar value ' 1 ' to
data type bit.))
,但如果我將其更改爲false它的工作原理。我會顯示一些我的代碼。我把它的大部分縮小了,因爲我已經縮小到這個變量了:
$active = True;
這裏是我的插入查詢。
$sqlInsert = "INSERT INTO customers(
customerID,
registeredDate,
givenName,
familyName,
email,
password,
phone,
mobile,
property,
street,
locality,
town,
area,
postalCode,
active
)
VALUES(" .
$newUser . "," .
$date . ", ' " .
$given . " ', ' " .
$family . " ', ' " .
$email . " ', ' " .
$pwd . " ', ' " .
$phone . " ', ' " .
$mob . " ', ' " .
$property . " ', ' " .
$street . " ', ' " .
$locality . " ' , ' " .
$town . " ', ' " .
$area . " ', ' " .
$postalcode . " ', ' " .
$active . " ')";
$stmtInsert = sqlsrv_query($conn, $sqlInsert);
爲什麼是假的,雖然工作? – 2012-04-29 13:10:15