Solved

binding column of type bit in update query

Posted on 2014-12-06
2
124 Views
Last Modified: 2014-12-06
In this setup, the name column (type is nvarchar(50)) updates just fine.

I cannot get the two other columns (IsFrequentlyUsed & IsActive , both of type bit) will not update.  

I have confirmed that their values are passed in correctly and I have tried to convert them to 1 or 0 as well.  In any case, they do not update.  Is there some consideration for bit type columns in this setup?

$sql = "UPDATE Color 
		SET
		Name =?,
		IsActive = ?,
		IsFrequentlyUsed = ?
		WHERE Id=?";

$params=array( &$Name, &$IsActive,&$IsFrequentlyUsed,&$Idin);

$stmt = sqlsrv_prepare( $conn, $sql, $params, array("Scrollable"=>"buffered"));

if(sqlsrv_execute( $stmt )){

	//query succeeds
	

}else{

	//query failed
	
}

Open in new window

0
Comment
Question by:Zipbang
  • 2
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40484797
Using true and false instead of 1 and 0  should work

You can also give more input about a parameter instead of just the value
$params = Array( Array(&$param1, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_INT, SQLSRV_SQLTYPE_BIT) );Please try that kind of code
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40484798
No errors?
You may have better results using true/false instead

Or give more input to your parameters like this
$params = Array( Array(&$param1, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_INT, SQLSRV_SQLTYPE_BIT) );Please try that
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now