Page 1 of 1

MSSQL_EXECUTE returns no data

Posted: Fri Aug 23, 2013 6:39 pm
by sasidhar79
Hi,

I am moving from .net/MSSQL to PHP/MSSQL for obvious reasons, I am new to PHP. My PHP code
setup is
PHP on Ubuntu 12.04
MSSQL on Windows server.

Code: Select all

$paramDueDateBy = "Today";
	$paramUserName = "MB";
	$paramDueDateFrom = "2009-10-10 00:00:00";
	$paramDueDateTo ="2013-10-10 00:00:00";
	
	
	$conn =  connect_db() or exit('Db connect failed...');
	
	
	// Bind values
	
		$stmt = mssql_init('GetToDoList',$conn);
		
		mssql_bind($stmt, '@strDueDateBy',    $paramDueDateBy,  SQLVARCHAR, false, false,50);
		mssql_bind($stmt, '@strScheduleTo',   $paramUserName,   SQLVARCHAR,false, false,50);
		mssql_bind($stmt, '@strDueDateFrom',   $paramDueDateFrom,   SQL_DATE,false, false,50);
		mssql_bind($stmt, '@strDueDateTo',   $paramDueDateTo,   SQL_DATE,false, false,50);
		//exit;
		$result = mssql_execute($stmt);
mssql_execute is not returning any resultset it is empty and the code after this does not get executed. Am i missing anything ? please help

Re: MSSQL_EXECUTE returns no data

Posted: Fri Aug 23, 2013 8:02 pm
by requinix
What are the values of $stmt and $result? Have you already set up your environment for development and debugging by setting

Code: Select all

error_reporting = -1
display_errors = on
in your php.ini?

Also, the mssql extension is dead. If you're running on Windows you should be using the SQLSRV extension from Microsoft instead.

Re: MSSQL_EXECUTE returns no data

Posted: Sat Aug 24, 2013 11:30 am
by sasidhar79
Thank you very much. I have not done those settings yet.
SQLSRV works only on windows ? what should i use if i am running on Linux. ?

Re: MSSQL_EXECUTE returns no data

Posted: Sat Aug 24, 2013 6:41 pm
by requinix
As long as mssql still works for you, you can keep using it. There's also rumors about sqlsrv for Linux, or MS suggesting using ODBC, or FreeTDS which is apparently unstable.