Jump to content


Photo

Connection Error


  • Please log in to reply
1 reply to this topic

#1 2minutes2midnight

2minutes2midnight

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 14 March 2014 - 09:16 PM

I was an ASP programmer and now trying to convert to php.  I cannot get my driver to connect to the database.  The issue is the same if I use PDO or the older method. 

 

Here is the connection string...

 

try {
  # MS SQL Server and Sybase with PDO_DBLIB
  $DBH = new PDO("mssql:host=$hostname; dbname=$database;" , $username, $password);
  echo "Connected to Test<br>";
}
catch(PDOException $e) {
    echo "Error=" . $e->getMessage();
}

 

Here is the result...

Error=could not find driver

 

I have found this page and done everything on it but still does not connect....

http://stackoverflow...not-find-driver

 

Any ideas?



#2 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 2,016 posts

Posted 15 March 2014 - 04:44 AM

The link you posted to is for the MySQL database PDO driver. This is not the same driver for accessing an MSSQL (Microsoft SQL) database

 

To access an MSSQL database with PDO you either have to use the ODBC PDO driver or download the MSSQL driver provided by Microsoft, linked to in the manual here


Edited by Ch0cu3r, 15 March 2014 - 04:48 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com