0

I'm trying to connect to a SQL Server 2008 from a Linux,PHP (cPanel, Greengeeks.com).

Server admin says that he added the Linux server IP to Firewall and enabled TCP/IP connection, port is 1433.

But I still can't connect tot he server.

The Error message is:

SQLSTATE[01002] (null) (severity 9)

Connection script is:

 <?php
  try {
    $hostname = "999.999.255.239\INSTANCENAME";
    $port = '1433';    
    $dbname = "database";
    $username = "user";
    $pw = "pass";
    $dbh = new PDO ("dblib:host=$hostname;dbname=$dbname;","$username","$pw");
  } catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
  }

Please help

jarlh
  • 42,561
  • 8
  • 45
  • 63
D.Shinekhuu
  • 307
  • 3
  • 12
  • 2
    Have you installed the mssql driver for php on you Linux OS? – Nurjan Oct 28 '16 at 06:13
  • @Nurzhan yes I think I did, please take a look at the screenshot of my cPanel PHP Settings http://prntscr.com/czx7f3 – D.Shinekhuu Oct 28 '16 at 06:38
  • Look here http://stackoverflow.com/questions/24895605/php-pdo-mssql-sqlstate01002-adaptive-server-connection-failed-severity-9 – Nurjan Oct 28 '16 at 06:45

1 Answers1

1

Maybe you can var_dump( $dbh->errorCode() . ' ' . $dbh->errorInfo()); to help you knowing what's wrong with your connection. You know that is necessary to check error with your important steps.

Vincent
  • 84
  • 6