PHP: Connecting PDO to SQL Server - php

I know that there is some discussion on PHP & SQL Server, but most of this is a few years old, and predates PHP; not much mentions PDO either.
I have a client who wants to access their SQL Server database from their web server. The Web Server is Apache running on Ubuntu Linux, while the SQL Server is running on a separate Windows box.
Most of what I have been able to find is dated, especially since PHP 7 came out.
What do I need to install to get PHP & PDO connecting to to a remote SQL Server?

Related

Remote MS ACCESS connection with PHP ODBC on CentOS [duplicate]

Does anyone know if it's possible to connect and query an MS Access database from a Linux Server using PHP?
If it is possible I'm thinking install ODBC driver on the Linux server, but will it work to connect to Access is the question. I've read it's possible with MSSQL.
My knowledge is very limited when it comes to any Windows related DBs so any advice much appreciated.
Yes, it's possible. I've done it using ODBTP, which took advantage of the ODBC driver on the (Windows) machine that hosted the Access database file.
It's also theoretically possible to use an ODBC driver on the Linux server to read an Access database on a Windows networking share if the Linux box can "see" it. However, I've never had very good luck with Access ODBC on Linux so I wouldn't recommend spending too much time trying to get it working.

Connect to remote MS Access database from Linux Server using PHP

Does anyone know if it's possible to connect and query an MS Access database from a Linux Server using PHP?
If it is possible I'm thinking install ODBC driver on the Linux server, but will it work to connect to Access is the question. I've read it's possible with MSSQL.
My knowledge is very limited when it comes to any Windows related DBs so any advice much appreciated.
Yes, it's possible. I've done it using ODBTP, which took advantage of the ODBC driver on the (Windows) machine that hosted the Access database file.
It's also theoretically possible to use an ODBC driver on the Linux server to read an Access database on a Windows networking share if the Linux box can "see" it. However, I've never had very good luck with Access ODBC on Linux so I wouldn't recommend spending too much time trying to get it working.

Connection error to sql server when doing massive queries with sqlsrv

i was wondering if anyone knows why i am getting the following error.
I have an application doing massive queries to a SQL 2008 Server. The main application runs over PHP on linux , I call many php scripts simultanously to a windows server running PHP over xampp, this server queries the sql database and this is where I am getting the error.
On this windows server I hava PHP 5.4.4 with the sqlsrv extension. I have the sql server configured to handle unlimited connections. however when I send many API calls (thousands) i eventually start getting connection errors like the one below,
Unable to connect to server
I read that mssql conection can be tuned with the max_procs config, however I am using sqlsrv extension instead and I havent found any info regarding this .
Has anyone experienced this issue before.
Thanks in advanced.

Connect to Mssql 2008 sever remotely through php

Quick question: I am having issues while trying to connect to a mssql 2008 server through php. The php script is located on a different server. Does the mssql server have to have php installed on it? or only the server which I am running the script from?
Only the server you are running PHP on. If there's a connection error, you may be having issues with you connection string or with the raw networking (for instance, the port you are trying to connect to is blocked on the remote server).
If you take a look at the documentation for mssql in PHP, you can see that it accepts both local and external addresses (computer or server, port).
The server running mssql, to which you're connecting, doesn't need PHP enabled.

Connecting to external MySQL DB from a web server not running MySQL

While I've been working with MySQL for years, this is the first time I've run across this very newbie-esq issue. Due to a client demand, I must host their website files (PHP) on a IIS server that is not running MySQL (instead, they are running MSSQL). However, I have developed the site using a MySQL database which is located on an external host (Rackspace Cloud). Obviously, my mysql_connect function is now bombing because MySQL is not running on localhost.
Question: Is it even possible to hit an external MySQL database if localhost is not running MySQL?
Apologies for the rookie question, and many thanks in advance.
* To clarify, I know how to connect to a remote MySQL server, but it is the fact that my IIS web server is not running ANY form of MySQL (neither server nor client) that is giving me trouble. Put another way, phpinfo() does not return anything about MySQL. *
Yes, you can use a MySQL database that's not on the same machine as Apache+PHP.
Basically, you'll connect from PHP to MySQL via a network connection -- TCP-based, I suppose ; which means :
MySQL must be configured to listen to, and accept connections on the network interface
Which means configuring MySQL to do that
And given the required privileges to your MySQL user, so he can connect from a remote server
And PHP must be able to connect to the server hosting MySQL.
Note, though, that habing MySQL on a server that's far away might not be great for performances : each SQL query will have to go through the network, and this could take some time...
If phpinfo is not returning anything about MySQL you need to install the MySQL plugin for PHP, easiest way to do that probably is to just upgrade PHP to the latest version. If not there is a .DLL file that you will need.
http://www.php.net/manual/en/mysql.installation.php
you will need to install the mysql extensions. this link should help: http://php.net/manual/en/install.windows.extensions.php
The MySQL server has nothing to do with PHP itself. What "mysql support" in PHP means is that it's been compiled with (or has a module loaded) that implements the MySQL client interface. For windows, it'd be 'mysql.dll', and on Unix-ish systems it'd be 'mysql.so'. Once those are loaded, then the various MySQL intefaces (mysql_xxx(), mysqli_xxx(), PDO, MDB2, etc...) will be able to access any MySQL server anywhere, as long as you have the proper connection string.

Categories