Pooja Kshatriya Pooja Kshatriya - 1 year ago 356
PHP Question

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download