2

I want to connect a cloud mssql server from my xampp localhost using pdo? How to do that?

try {
    $hostname = "xxxxxx";
    $dbname = "xxxxxx";
    $username = "xxxxxxx";
    $pw = "xxxxxxx";
    $dbh = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");
  } catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
  }

it gives error Failed to get DB handle: could not find driver

i dont know any other information about the db...only i know is that it is a cloud mssql database...pls help me in this

my localhost php version is 5.6.31 i am using xampp in windows 7

Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72
Rahul
  • 159
  • 2
  • 15
  • Maybe the odbc driver is available, the manual (http://php.net/manual/en/ref.pdo-dblib.php) says that also should work. Take a look at https://stackoverflow.com/a/31105561/3783243 – user3783243 Jan 12 '19 at 12:33
  • https://stackoverflow.com/questions/27126338/xampp-ms-sql-server-php-5-6 https://stackoverflow.com/questions/34401170/this-extension-requires-the-microsoft-odbc-driver-11-for-sql-server-to-communica this two link solved my problem – Rahul Jan 12 '19 at 12:48

0 Answers0