Stack Exchange
PHP SQLSRV invalid parameter passed in update query
I am getting this error
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -14 [code] => -14 [2] => An invalid parameter was passed to sqlsrv_query. [message] => An invalid parameter was passed to sqlsrv_query. ) )
code is:
 $sql_query = "UPDATE Subscription SET Status = ? where SubscriptionID = ?";
        $params = array(1, $subscription_id);

        $stmt = sqlsrv_query( $conn, $sql_query, $params);

        if( $stmt === false ) { echo " Error occurred while updating in database. "; 
            die( print_r( sqlsrv_errors(), true));}
        else {echo " Database updated successfully.";}

someone please help me... Thanks

to debug this more, can you hard-code the value in place of ? in the query and see if it works or it is failing? $params is an optional argument to sqlsrv_query
The problem was that the $conn was null.

I hard coded the values still showing the same eror

var_dump the $conn to make sure it is correct....also try if any query works...with sqlsrv_query or is this specific UPDATE query which is not working.

Thank you so much, conn was null. fixed
