MSSQL_EXECUTE returns no data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sasidhar79
Forum Newbie
Posts: 2
Joined: Fri Aug 23, 2013 4:59 pm

MSSQL_EXECUTE returns no data

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MSSQL_EXECUTE returns no data

Post 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.
sasidhar79
Forum Newbie
Posts: 2
Joined: Fri Aug 23, 2013 4:59 pm

Re: MSSQL_EXECUTE returns no data

Post 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. ?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MSSQL_EXECUTE returns no data

Post 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.
Post Reply