Ugh. I've spent hours searching for a solution for this, so it's probably something simple. I have a stored procedure in SQL Server (2008) that I'm trying to call from PHP code. I'm using ODBC, and everything works if I use a hard-coded SQL statement.
But I'm trying to call a stored procedure that returns a set of rows (cursor, dataset, etc.), passing two parameters. When I run the code through my browser I just get a 500 http error. It is bombing on the odbc_execute() line. Here's my code:
// DSN-less connection:
$conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", '', '');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$fromDate = new DateTime('2012-1-1');
$toDate = new DateTime('2013-12-31');
$sql = odbc_prepare($conn, "{call GET_EVENTS_BY_DATE_RANGE(?, ?)}");
$params = array($fromDate, $toDate);
$result = odbc_execute($sql, $params);
if ( $result === false)
{
exit("Query failed");
}
odbc_close($conn);
Again, no problems until it hits the odbc_execute() function. Any help is appreciated.
PHP Warning: odbc_execute(): SQL error: [Microsoft][ODBC SQL Server Driver]Cursor type changed, SQL state 01S02 in SQLExecute in C:\bleah\sp.php on line 24odbc_exec() expects parameter 2 to be string, array given in C:\....