ODBC error in PHP: “No tuples available at this result index”

opener

New Member
Been looking for this on Google for a while, but still looking. Couldn't turn up anything on it.Using PHP to query MS SQL Server via ODBC. Code is below: (I've watered it down to bare-bones as I've tried to debug this)\[code\] $SQL=<<<HEREDOCDECLARE @weekStart SMALLDATETIME;SET @weekStart = DATEADD(d,0, DATEDIFF(d,0,GETDATE()));SET @weekStart = DATEADD(d, 1-DATEPART(dw, GETDATE()), @weekStart);SELECT DATEDIFF(week, Run_Date, @weekStart) AS weeksAgo ,MIN(Current_List) AS list ,COUNT(*) AS cnt ,SUM(NoContact_90Days) AS noContact90 ,SUM(NoContact_180Days) AS noContact180 ,SUM(NoMtg_180Days) AS noMtg180 ,SUM(NoMtg_360Days) AS noMtg360FROM [someDB].[DBO].[someTable]WHERE Current_List<>''GROUP BY DATEDIFF(week, Run_Date, @weekStart) ,Current_ListORDER BY DATEDIFF(week, Run_Date, @weekStart);HEREDOC; $dbUser = "someUser"; $dbPass = "somePw"; $connStr = 'Driver={SQL Server};Server=someServer;'; $conn = odbc_connect($connStr, $dbUser, $dbPass) or die("Cannot start ODBC connection"); $rs = odbc_exec($conn, $SQL); $r = odbc_fetch_array($rs); die('ok');\[/code\]Getting a warning I've never seen on the odbc_fetch_array() line:\[code\]Message: odbc_fetch_array() [function.odbc-fetch-array]: No tuples available at this result index\[/code\]I've run the query in SQL Server Mgmt Studio and it returns a single set of records. I'm using this same connection string & method of retrieving the rows in other parts of the app with no problem. Any ideas?
 
Back
Top