Solved

sqlsrv generic errors

Posted on 2012-04-13
4
457 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
Comment Utility
What version of PHP, SQL server driver, etc.?
0
 

Author Comment

by:talonsblade
Comment Utility
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
Comment Utility
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
Comment Utility
figured out the error myself and it was a stupid one
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now