Solved

sqlsrv generic errors

Posted on 2012-04-13
4
462 Views
Last Modified: 2012-04-18
i have recently started getting generic errors with the sqlsrv php mssql plugin.  i have been using it for a while now and have had no problems.  recently I moved my entire site/ databases to a new server, moss 2010, mssql 2008.  with the sqlsrv plugin you can access sql2008 from php.  i have always used the code

     $retval = runQuery($conn,$tsql);
		if(sizeof(sqlsrv_errors(SQLSRV_ERR_ERRORS),0)>0){
			$myErrors = json_encode(array("status"=>"Failed","step"=>"Update tools","errors"=>json_encode(sqlsrv_errors())));
			sqlsrv_rollback($conn);
			die($myErrors);
		}

Open in new window

to run the sql statment and check to see if there were any errors.  this used to return the actualy SQL error returned from MSSql 2008.  since we have moved to the new server i have been getting a generic error that makes no sense.

the error we have been getting is

SQLSTATE:IMSSP,
code:-14,
message:An invalid parameter was passed to sqlsrv_free_stmt.

I get this error from sqlsrv no matter the SQL error.  i am trying to see if the person adding the record will hit a Key contraint but i cannot tell what the error was with this.  i get this error wether i use sqlsrv_free_stmt or not. i get it even if i remove all instances of sqlsrv_free_stmt from my php code.

i have done alot of searching on this and can find many examples of "An invalid parameter was passed to " but the are always to other functions.  never to sqlsrv_free_stmt
0
Comment
Question by:talonsblade
  • 3
4 Comments
 
LVL 14

Expert Comment

by:Scott Madeira
ID: 37844206
What version of PHP, SQL server driver, etc.?
0
 

Author Comment

by:talonsblade
ID: 37844435
PHP 5.3.5

sqlsrv 2.0  just noticed that 3.0.1 was released on april9, need to check that out
0
 

Accepted Solution

by:
talonsblade earned 0 total points
ID: 37844622
figured out my problem, i was using a function to run my sqlsrv statments that didnt return any data, so i can quickly run update/insert statments.  this function was on another page and included a sqlsrv_free_stmt.  when i quit using my function and just called sqlsrv_query i got the correct error.  dont know why i have never had this error before.
0
 

Author Closing Comment

by:talonsblade
ID: 37859744
figured out the error myself and it was a stupid one
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

776 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