?
Solved

sqlsrv generic errors

Posted on 2012-04-13
4
Medium Priority
?
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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…
Suggested Courses

649 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