1
I am trying to create a PHP connection with SQL Server 2008 but the server returns the following error:
Fatal error: Call to undefined function mssql_connect()
I’ve looked in many places and everyone says to go in PHP.ini and remove the comment from the line:
extension=php_mssql.dll
But my php.ini file does not have this line.
This is my current code, but I’ve tried several others:
<?php
mssql_connect("192.168.2.7", "sa", "5c@n9r1n7#@dm") or die("Não foi possível a conexão com o servidor");
mssql_select_db("fd_585b0f87") or die("Não foi possível selecionar o banco de dados");
mssql_close();
print "Conexão OK";
?>
I’ve tried that one too:
<?php
$server = "192.168.2.7";
$banco="fd_585b0f87";
$user ="sa";
$senha="5c@n9r1n7#@dm";
$conexao = mssql_connect($server,$user,$senha);
$conexao = mssql_select_db("$banco", $conexao);
if($conexao){
echo "conexao Certa";
}
?>
Does anyone know any way to fix that mistake?
Add the line in php.ini if it doesn’t exist. If it doesn’t work, you probably have to install that library. But first, try just adding the line. And this for PHP in windows, pq in linux and similar is not DLL, is SO.
– Bacco
According to the official documentation (http://php.net/manual/en/mssql.installation.php) you have to compile PHP with mssql, but this is +or- a kick, I never used m$ sql server with PHP.
– Olimon F.
First check if there is php_mssql.dll, if it does not exist it will not be able to load. If you are using linux it should be php_mssql.so in general it usually comes with php, create a php page and put the command: <?php phpinfo(); ? > go to this page, it will display everything your php supports, search this page for information about mssql.
– Sileno Brito
I already used PHP with MSSQL and the same error happened, I solved it through the link below. See if it helps, if yes put as an answer not to stay only the link: http://forum.imasters.com.br/topic/395466-resolvidoerro-ao-conectar-php-a-base-dados-sql-server-2005/
– Filipe Moraes