Solved

binding column of type bit in update query

Posted on 2014-12-06
2
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 143

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 143

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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