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