maliary Posted April 24, 2008 Share Posted April 24, 2008 Hi guys, I have a php program running on a server connecting to a MSSQL server on a different server and the connection works well. I moved the program to a virtual machine but for some reason there is no database connection any more. Is there a special way to connect to the database from a virtual machine ? Here is the working connection : class mssql { var $dbname; var $server; var $user; var $password; var $connection; /**Constructor**/ function mssql () { $this->dbname='[dbname]'; $this->server='192.168.0.5'; $this->user='sa'; $this->password='pass'; $this->connection = mssql_connect ($this->server,$this->user,$this->password); if ($this->connection) { mssql_select_db ( $this->dbname, $this->connection) or die ( 'Can not select database' ); return $this; } return false; } /**closes the mssql connection**/ function close () { return mssql_close ($this->connection); } /**shows the connection status.**/ function toString() { print "connected To: ".$this->connection; } /**performs a query **/ function query ($sql) { if ($sql) { $results= mssql_query ($sql, $this->connection); return $results; } return false; } } Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/ Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 Verify that you can access the server from the VM, and does the database connection return any errors? Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-526129 Share on other sites More sharing options...
maliary Posted August 21, 2008 Author Share Posted August 21, 2008 Sorry to bump an old post: Am getting the following error : Fatal error: Call to undefined function: mssql_connect() in C:\apache2triad\htdocs\care2x\include\care_api_classes\class_mssql.php on line 36 and yes I can connect to the server from the VM both by remoting and accessing it via its IP. Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622053 Share on other sites More sharing options...
Lamez Posted August 21, 2008 Share Posted August 21, 2008 can you post line 36!? Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622065 Share on other sites More sharing options...
maliary Posted August 21, 2008 Author Share Posted August 21, 2008 Line 36: $this->connection = mssql_connect ($this->server,$this->user,$this->password); Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622143 Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 Looks like you do not have the mssql extension enabled. Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622147 Share on other sites More sharing options...
maliary Posted August 21, 2008 Author Share Posted August 21, 2008 How do I enable it ? Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622152 Share on other sites More sharing options...
maliary Posted August 21, 2008 Author Share Posted August 21, 2008 I have tried this if (function_exists('mssql_fetch_row')) { echo "MSSQL functions are available. \n"; } else { echo "MSSQL functions are not available. \n"; } and it says MSSQL functions are available. what next ? Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622170 Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 Take a look at the output from a call to phpinfo(), are you sure its enabled? What OS is within the VM? Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622186 Share on other sites More sharing options...
maliary Posted August 22, 2008 Author Share Posted August 22, 2008 From the php out put it is enabled. The OS is Windows server 2003 Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622744 Share on other sites More sharing options...
maliary Posted August 22, 2008 Author Share Posted August 22, 2008 Find attached the phpinfo MSSQL report. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622764 Share on other sites More sharing options...
maliary Posted August 22, 2008 Author Share Posted August 22, 2008 Hi guys, The problem was that I was using an old version of ntwdblib.dll.Which is Version 2000.2.8.0. This doesn't work very well with MSSQL 2005 so I downloaded ntwdblib.dll 2000.80.194.0 which worked. I've seen several unanswered posts and I think this could be the solution to them. So guys, I wouldn't want you wandering in the internet jungle like I did, give yourself some peace and download this. Quote Link to comment https://forums.phpfreaks.com/topic/102736-solved-connecting-to-db-from-virtual-machine/#findComment-622808 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.