Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.2K
Vistas
PDO sqlsrv: could not find driver

I trying to connect to an SQL Server in PHP. With XAMPP on my local machine, everything works well. But now I going to bring my application on the production server.

On this server there is installed the Microsoft IIS 6.1 and running the PHP version 7.0.7. I also installed the ODBC Driver from here. Next I decomment the following line in my php.ini file:

extension=php_sqlsrv_7_nts.dll
extension=php_pdo_sqlsrv_7_nts.dll

I got the files from the official microsoft site.

What's my problem?

Unfortunately, after I restarted the IIS. The PDO function throws the PDOException error with the following message:

could not find driver

For the connection I am using the following function which works pretty well on my local machine:

try {
    $con = new PDO("sqlsrv:Server=" . SERVER . ";Database=" . DATABASE, USERNAME, PASSWORD);
    // set the PDO error mode to exception
    $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    echo "No connection: " . $e->getMessage();
    exit;
}

What can I else do?

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Here is detailed process if it's helpful for someone. PHP Version - 7.4

  1. Download and extract the .dll files from this link - https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver15

  2. Paste the files in C:\xampp\php\ext, your path could be different.

  3. in php.ini add those two lines at bottom or in extension section.

     extension=php_sqlsrv_74_ts_x64.dll
     extension=php_pdo_sqlsrv_74_ts_x64.dll
    
  4. Restart your Xampp server, I'll suggest restart your computer and everything will work without an issue then.

Check if SqlSRV enabled

Check using phpinfo() or http://localhost/dashboard/phpinfo.php at like this -

SQLSrv Driver Check in PHP Info

Hope, it will help someone.

about 4 years ago · Santiago Trujillo Denunciar

0

After I found the error log on the Windows Server, I solved the error by myself.

I got this error in my log:

[21-Apr-2017 07:12:14 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '...\ext\php_pdo_sqlsrv_7_nts.dll' - %1 is not a valid Win32 application. in Unknown on line 0

Then I downloaded again the driver and installed the x64-Driver. Finally It works without any problems.

about 4 years ago · Santiago Trujillo Denunciar

0

It took some time for me to solve the 'No driver'-error. I went through some steps as mentioned here and found some other ones that helped me after new errors. For future references:

  • Download the latest drivers from Microsoft (as said by Julian Schmuckli).
  • Check if your XAMPP is 64 bits(!) with Phpinfo(). If you've got 32-bit, you need different drivers.
  • Add the drivers to your Php.ini file and save the dll's in your php/ext-folder (question of saber tabatabaee yazdi).
  • For the connection, use this code:
$dbh = new PDO ("sqlsrv:Server=$server;Database=$dbname",$username,$pw); 

If you add a port, use:

$server = "192.168.1.15, 51022";

Where the IP (can be hostname to) is your server and 51022 your port.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda