I've got a problem and there doesn't seem to be a strait forward solution.
I'm running a Linux server with PHP and need to connect to a MSSQL database on a remote server (I don't have control over this server). Speaking to my host, they say that it's not possible eto install the MSSQL extensions on a linux box as they are only available on Windows Servers. So, I'm looking to see what other options i have.
Any ideas how I can do this on a linux box?!
it's not possible eto install the MSSQL extensions on a linux box
They lied. It is possible, but it requires FreeTDS to compile.
Other solution is to use other host (with windows) to act as proxy to MSSQL server, and communicate with it by SOAP/REST
you have to do it via an ODBC connection.. odbc_connect() etc etc.. Microsoft has drivers for this http://www.microsoft.com/en-gb/download/details.aspx?id=28160.. (edit) I have done this without any of the issues posted... the php.net website for odbc_connect even gives mSSQL examples in the manual http://php.net/manual/en/function.odbc-connect.php
Maybe this helps, send it to your server host:
http://pointbeing.net/weblog/2010/05/successful-microsoft-sql-server-support-for-php-on-linux.html
Commonly a database module is installed but in your case you could try to use a REST-API to talk with the MSSQL database. But that must be installed on a second server e.g. the database server itself.
Related
I would like to know how to compile mssql in php5.4 of Openshift? I've heard of freetds, but really I'm a bit of a novice with this and have not managed to make it work.
I want to connect to a remote server from my application MSSQL OpenShift php.
you can with a rhc code or install a DIY cartridge?
please help
OpenShift Online does not currently have any of the modules that you would need to connect to MSSQL installed. You have a couple of options:
Visit https://openshift.uservoice.com and add a suggestion for installing modules that would enable you to connect to a remote MSSQL server from the PHP cartridges.
Write an API in front of the MSSQL database that enables you to interact with it in the way that you need to. Maybe using another hosting provider that has the MSSQL extensions installed or a windows hosting provider,etc
Ubuntu 12.04 LTS Precise
I'm trying to use PHP to connect to a remote Windows Sybase database. Let us assume Windows 7 Enterprise SP1. I'm currently doing this in PHP:
$db = sybase_connect("10.1.208.111", "$user", "$pass");
And I'm getting an error of:
Warning: sybase_connect(): Unable to connect to server: 10.1.208.111
I understand that the server I'm connecting to (10.1.208.111), needs to be in the interfaces file. I'm trying to figure out where that is, or even if I have one on the Ubuntu server (I'm still new to linux itself). I read that the path for the file is located in the SYBASE environmental variable. I don't know where that is either. Can anyone shed some light? I can offer more information if you need it, I just don't know what you need right off the bat.
PS: The windows machine has Micros RES installed on it. That's the database I'm trying to pull data from. Not sure if that matters.
The default installation directory for Sybase ASE in windows is C:\sybase, so your interfaces (interfaces.ini) should be located there.
For SQL Anywhere, the interfaces file is called SQL.ini, and it's location varies, but you should be able to do a search of your system drive to find it.
For SQL Anywhere you probably want to use the PHP apis that are provide by SAP Sybase. The SQL Anywhere documentation is a pretty good place to start, as it covers all the pieces that need to be installed to get SQL Anywhere to talk to PHP.
SQL Anywhere 11: SQL Anwhere PHP API
You may also be able to find good information over at the SAP Community Network site for SQL Anywhere.
Im trying to run a shell with cakephp but I'm not able to do it due to a SQL connection error, I'm always getting this
Warning:mssql_connect(): Unable to connect to server: XXXXX I'm sure the config for the data source is correct as I'm able to connect using the website side of the app.
Have anyone stumble with something like this?
BTW the webserver and the mssql server are not the same, they are on different hosts.
Environment Info ( I agree is a mess... ):
Web server
Windows server 2003 R2
PHP-5.2.4
IBM http server 6.1
Cakephp 1.2
DB Server
Windows server 2003 R2
Microsoft SQL server 2005
I have isolated the problem and found is not cakephp related, I created a script with just this line of code
mssql_connect('XXXX', 'YYYY', 'ZZZZ', true);
Giving me the same error. This should be something different between CLI and how php is run from the HTTP server.
Thank you!
Make sure you specify the port to connect to (usually 1433). If that still doesn't work its possible you need to play with named pipes settings. More information can be found in the comments on the PHP site: http://ca3.php.net/function.mssql-connect
I would also suggest you look into using the Microsoft SQL Serv drivers for PHP, they are much better maintained than the mssql ones. http://www.microsoft.com/download/en/details.aspx?id=20098 Here is an article explaining the differences: http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx If you do go the sqlsrv route (and I really suggest you do) here are the connection parameters: http://php.net/manual/en/function.sqlsrv-connect.php Use example 3.
Here are the steps I followed to narrow and then fix the problem:
Check which php.ini is your cli using by running the next command: php -i
Isolate the problem, I was thinking it was something with cakephp, but at the end every problem is related to a single line in php, my problem was around this line of code mssql_connect('XXXX', 'YYYY', 'ZZZZ', true);
Based on the info provided here I found out that the next dll was outdated or not compatible with Windows Server 2003, just get ntwdblib.dll ver. 2000.80.2039.0, use this exact version as others like ver.2000.80.194.0 didn't worked for me.
As #charles mentioned if you are not working already in a project already deployed use sqlsrv drivers as those are maintained currently and the mssql are basically getting deprecated.
Thanks!
I'm interested in quering a Pervasive DB server running on a Windows platform from Linux.
Would anyone happen to know if this is possible, what's required and what resources there are for me to read up on it?
Thanks!
What version of Pervasive are you using? All versions since v8 (including v9 and v10) support a Linux client which is included with the Pervasive.SQL server engine. V9 and V10 clients are also available for download from the Pervasive website (http://www.pervasivedb.com/Database/Products/PSQLv10/Pages/PSQLOverview.aspx). Once you've got a client installed on the Linux machine, you can create an ODBC DSN or use the Btrieve API to access the data.
Most database have at least a command line client to connect to database. check your brand of database to see if you have such tools. For example, Mysql has mysql command line client for making query to MySql database. Otherwise, another way is you might want to try setting up ODBC with Perl.
I've inherited some code that uses the sqlsrv_connect method to instantiate a connection to a SQL Server database. My personal development machine is an OS X box that I'm running apache an PHP on. I have an instance of SQL Server running in a virtual machine.
When I attempt to connect to the database, I get the following error.
Fatal error: Call to undefined function sqlsrv_connect() in ...
It appears that sqlsrv_connect is not part of standard PHP, and is part of a driver that ships with SQL Server 2005. (please correct me if I'm wrong here)
Is there a way to use this function on Non-Windows platforms? I realize I could install/build an Apache/PHP instance on my Windows machine, but if there's a way to get this function working on OS X (or other *nixes) I'd prefer it.
Is not possible. The SQL Native Driver for PHP is Windows only product:
The SQL Server Driver for PHP relies
on the Microsoft SQL Server 2005 ODBC
Driver to handle the low-level
communication with SQL Server. As a
result, the SQL Server Driver for PHP
is only supported on Windows.
You can look here for a tutorial on how to install the extension. (Via Google)
I'm not too famillar with the extension, but that source should be able to help you out.
(Updated Link to Better Source, still via Google)
The SQL Server Driver for PHP (from MS) is available only on Windows. Unless you want some specific features offered by this driver/ API, you can use the PHP ODBC module along with UnixODBC/ iODBC driver, or FreeTDS (ODBC or db-lib)