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

3
  • 2
    Have you installed the mssql driver for php on you Linux OS? Commented Oct 28, 2016 at 6:13
  • @Nurzhan yes I think I did, please take a look at the screenshot of my cPanel PHP Settings prntscr.com/czx7f3 Commented Oct 28, 2016 at 6:38
  • Look here stackoverflow.com/questions/24895605/… Commented Oct 28, 2016 at 6:45

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.