0

Connect external MS SQL DB from Zend Framework on Linux Server

i have Linux Server where i want my Zend Framework, and want to connect my SqlServer Database which is on Other windows hosting Sever, i have installed database on that and having Database static link to connect with that.

but how can i connect with mssql database form linx sever ?

$server='some ip add'; $username='uname'; $password='passpass';
$database ='dbname' ;

$connection = mssql_connect($server, $username, $password)or die('Could Not Connect');
echo "test2";
if($connection != FALSE){
    echo "Connected to the database server OK<br />";
}
else {
    die("Couldn't connect" . mssql_get_last_message());
}

if(mssql_select_db($database, $connection)){
    echo "Selected $database ok<br />";
}
    else {
    die('Failed to select DB');
}

this code returns nothing!

any buddy connected mssql sever from linux hosting ?

2
  • Turn on error reporting (error_reporting(-1);). Chances are your host doesn't have the MSSQL extension loaded. Use PDO. Commented Sep 26, 2012 at 13:24
  • done with - print_r(get_loaded_extensions() ); not seems the sqlsrv drivers any where ! Commented Sep 26, 2012 at 13:31

1 Answer 1

1

I'm using multidb settings in the application.ini file since I have several different databases I'm pulling from but yes. Here is my settings from the ini file. You'll just have to make sure you have the drivers installed and setup correctly.

resources.multidb.tw.adapter = "pdo_mssql"
resources.multidb.tw.pdoType = dblib
resources.multidb.tw.charset = "utf8"
resources.multidb.tw.host = "192.168.1.111"
resources.multidb.tw.username = "username"
resources.multidb.tw.password = "passwd"
resources.multidb.tw.dbname = "database"
resources.multidb.tw.default = true

Hope that helps. Rois

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.