Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to connect to sql server using php using following code:

$myServer = "server";
$myUser = "username";
$myPass = "password";
$myDB = "test";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer");

Getting following error:

Fatal error: Call to undefined function mssql_connect() in /var/www/echdp/mssql_connection.php on line 26

Using php version

PHP Version 5.3.2-1ubuntu4.2

I have googled it many time and also try to search php_mssql extension but not found. Also search to install mssql extension but not find a useful link/tutorial .

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

If mssql_connect() is not available then it sounds like the MSSQL module isn't installed. You can check this with the phpinfo() function which will list all your compiled modules.

On Ubuntu you should be able to install the module from a package:-

apt-get install php5-sybase

(this is the Sybase/MSSQL Server module for php5)

...or as the previous answers states, compile from source with MSSQL flag

share|improve this answer
add comment

Have you tried recompiling PHP with the switch --with-mssql[=DIR]?

share|improve this answer
 
can you add some more detail that how to use switch. –  Awan Oct 11 '10 at 7:07
 
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.