sql - IF statement evaluating bit from php -


i have form posting script. there value on form called stat. here how handle it:

$data['stat'] = isset($_post['stat']) ? true : false; echo "stat value: " . var_dump($data['stat']); 

the output (i testing false response:

bool(false) stat value: 

my relevant sql evaluate value:

@stat               bit -- inserted data if @stat = 1     declare @newconsultid int     select @newconsultid = scope_identity()     exec insertfacilitydecision @newconsultid, 'emergency request', null, 17 

what happening insertfacilitydecision stored procedure being called, though false values being passed stored procedure.

am evaluating bit incorrectly?

you should enclose begin ... end statements supposed executed on if condition

if @stat = 1 begin     declare @newconsultid int     select @newconsultid = scope_identity()     exec insertfacilitydecision @newconsultid, 'emergency request', null, 17 end 

begin end can ommited single command only, in case was:

if @stat = 1     declare @newconsultid int -- statement under condition  -- 2 below not select @newconsultid = scope_identity() exec insertfacilitydecision @newconsultid, 'emergency request', null, 17 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -