Problems loading "mssql" in PHP

1

I'm 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 searched in many places and they all say to go in PHP.ini and remove 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 more:

<?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 this 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 of any way to fix this error?

    
asked by anonymous 21.06.2014 / 15:07

1 answer

1

You may need to update the php driver to access mssql, you can download the updated driver directly from the Microsoft website ( Microsoft Drivers 3.0 for PHP for SQL Server ) you also have the option to use pdo to connect to mssql. In the php site in the mssql part there is also the syntax of how to use, several comments on compatibility and information about the depreciation of commands at the bottom of the page plus solution links that can be enlightening and end up serving as a solution, but I believe that just upgrading should resolve.

Make sure you have the necessary library to use mssql, ie if the dll file or only (physically depending on the operating system) physically exists, create a file to read what your server supports

<?php 
phpinfo();

After creating the file, make sure that mssql is present among the supported features. Another thing that can help a lot is to check the log file.

    
26.06.2014 / 22:03