Page 1 of 1

'PDOException' with message 'could not find driver'

PostPosted: 26. December 2013 19:33
by bruceaj
I get the following error message

'PDOException' with message 'could not find driver'


This is the block of code that generates the error message.

Code: Select all
$connectParm = 'mssql:host=localhost;dbname=ervitals;charset=utf8,ervitals,Ejoe2tedR@';

   $connect = new PDO($connectParm); // The failure occurred on this line

   $SQL = "SELECT obituaryid,datafileid FROM obituaries";
   $SQL .= " WHERE year=?";
   
   $stmt = $connect -> prepare($SQL);
   $year = $_POST['txtYear'];
   $stmt -> bindParam(1,$year);
   
   $stmt -> execute();


What do I need to do to eliminate this problem?

Thank you..

Re: 'PDOException' with message 'could not find driver'

PostPosted: 26. December 2013 20:00
by Altrea
You want to use the pdo mssql driver but did not install it.
http://www.php.net/manual/en/ref.pdo-sqlsrv.php

Re: 'PDOException' with message 'could not find driver'

PostPosted: 27. December 2013 03:33
by bruceaj
I must have it installed because PDO works in another page I have. Since it works on another page, I must have a code problem somewhere but I don't know what to look for. I was going to reinstall XAMPP until I saw this other page.

Re: 'PDOException' with message 'could not find driver'

PostPosted: 27. December 2013 03:38
by Altrea
bruceaj wrote:I must have it installed because PDO works in another page I have.

PDO is not the problem, the missing mssql database driver is the problem.

bruceaj wrote:Since it works on another page, I must have a code problem somewhere

No, you have a missing mssql database driver problem.

bruceaj wrote:I was going to reinstall XAMPP until I saw this other page.

reinstallation of XAMPP will not solve the problem.