开发者

Moving php script from IIS to Linux- Script fails

Hi I have the following script which works fine running on IIS but when I put the same script on a Linux box it fails with the following error. Should this not just work?

Fatal error: Call to undefined function mssql_connect() in /home/thePathToTheScript/services/dhTest.php on line 10

Line 10 = $dbhandle = mssql_connect($myServer, $myUser, $myPass)

//start
$myServer = "SQLB15.sqlDBCenter.com";
$myUser = "unc_user";
$myPass = "unc1234";
$myDB = "db_Stuff"; 

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

//select a database to work with
$sel开发者_如何学编程ected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB"); 

//declare the SQL statement that will query the database
$query = "SELECT DISTINCT Name As theName";
$query .= "FROM tb_Names ";
$query .= "ORDER BY Name";

//execute the SQL query and return records
$result = mssql_query($query);
//---------------------------------------------------------------- 

Any pointers much appreciated

Added - this is the mssql section of the php.ini [MSSQL] ; Allow or prevent persistent links. mssql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit. mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent). -1 means no limit. mssql.max_links = -1

; Minimum error severity to display. mssql.min_error_severity = 10

; Minimum message severity to display. mssql.min_message_severity = 10

; Compatability mode with old versions of PHP 3.0. mssql.compatability_mode = Off

; Connect timeout ;mssql.connect_timeout = 5

; Query timeout ;mssql.timeout = 60

; Valid range 0 - 2147483647. Default = 4096. ;mssql.textlimit = 4096

; Valid range 0 - 2147483647. Default = 4096. ;mssql.textsize = 4096

; Limits the number of records in each batch. 0 = all records in one batch. ;mssql.batchsize = 0

; Specify how datetime and datetim4 columns are returned ; On => Returns data converted to SQL server settings ; Off => Returns values as YYYY-MM-DD hh:mm:ss ;mssql.datetimeconvert = On

; Use NT authentication when connecting to the server mssql.secure_connection = Off

; Specify max number of processes. Default = 25 ;mssql.max_procs = 25


You are trying to use the mssql extension, which is probably not loaded. You need to check your php.ini and look for "extension=mssql.so", then uncomment it and restart Apache.

If this extension it is not there, or if it does not work (errors when restarting apache or when running the script), then you will need to check with your Linux distribution what additional packages do you need and how to make it work.


You don't have the MS SQL extension installed on your Linux box.

See the PHP docs how to install/configure MS SQL

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜