D.Shinekhuu
D.Shinekhuu

Reputation: 307

Connect to SQL Server from Linux, PHP

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

Upvotes: 0

Views: 536

Answers (1)

Vincent
Vincent

Reputation: 69

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.

Upvotes: 1

Related Questions