0
I cannot run a PHP system on the server (Centos 6). When I try to connect to a MSSQL database the following error appears:
Call to undefined function mssql_connect()
My localhost works normally. The PHP version on the server is 5.4
The file connecting to the bank:
<?php
//conexão com o sql server
$host='*****';
$user='****';
$database='***';
$pass='****';
$con=mssql_connect($host, $user, $pass) or die ("Erro de conexão com o banco de dados") ;
mssql_select_db("$database") or die ("Erro ao selecionar banco de dados");
?>
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
; Compatibility 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. -1 = library default
; msdlib defaults to 25
; FreeTDS defaults to 4096
;mssql.max_procs = -1
; Specify client character set.
; If empty or not set the client charset from freetds.conf is used
; This is only used when compiled with FreeTDS
;mssql.charset = "ISO-8859-1"
The functions
mssql_*()
no longer exist– Jéf Bueno
@Jéfersonbueno, which function I use then to connect with SQL Server?
– Amanda Lima
You have SQL Server in the Hundreds?
– Jéf Bueno
No. But the database I need to connect to is on a Windows server and my system needs to be on the Centos server
– Amanda Lima
@Amandalima in UNIX environment, in the case of Ubuntu I use PDO only. Try running these commands: sudo apt-get install php5-Sybase php5-odbc freetds-common
– juniorb2ss
@juniorb2ss, the Centos package manager is YUM. php5-Sybase is not available in repositories. I’ll look for these packages some other way, thanks for the tip.
– Amanda Lima
Truth @amandaLima did not pay attention to this detail, I only use Ubuntu. It will have to be by RPM. See if it helps you: http://www.dicas-l.com.br/arquivo/mssql_com_php_no_centos_5.4.php
– juniorb2ss
Which version does Sqlserver use?
– rray
@rray is SQL Server 2008. I could not connect via PDO tbm no. :(
– Amanda Lima
Amanda, I recently had to make a connection to SQL SERVER using the mssql_connect() function. That’s what you need?
– Diego Souza
Yes, that’s what I needed, I already got :) The problem was the PHP version installed. I changed the version and it worked well
– Amanda Lima