Does anyone know why mssql_connect would be slow? PHP is running on a Linux server with FreeTDS. I am trying to connect to a remote database. When I connect from PHP it takes about 3 seconds, but if I use the FreeTDS tsql command from the shell it connects in under a second, so it is able to connect faster. Is there a setting I can change or a different driver I should use?
You should start using PDO with MSSQL driver support.
More info on:
http://php.net/manual/en/ref.pdo-dblib.php
And some examples:
Connecting to mssql using pdo through php and linux
Related
I have already Docker and SqlServer which is works normally. Now i want to connect to sql server with php. it gives me could not find driver error. I use php 8 on centos 7. How can i fix it?
I have problem with connection to Vertica database from PHP code.
The situation is this:
I'm working on Windows 7,
I installed ODBC driver for Vertica, set it up and test connection was successful,
Vertica is running on virtual machine in VirtualBox, I can connect to it via ssh dbadmin#192.168.56.102.
I have tried all possibilities I've found but nothing worked. PDO cannot find server, odbc_connect is saying no driver exists.
Has anybody have idea please?
Thanks you very much.
J.
I am using Php to connect the SQL server using these code:
$dbhandle = mssql_connect($server,$username,$password);
or die("Could not connect to SQL server");
$selected = mssql_select_db($database,$dbcon)
or die("Could not open database $database");
However, I found that the code does not run. No error message and cannot do any mssql_query() with this.
After some research, I found that mssql is not default supported by Php 5.5 like mysql. However, I do not find the sulotion.
I found this from Microsoft but they are for Php on Windows. I cannot find the one for Linux
http://www.microsoft.com/en-us/download/details.aspx?id=20098
What should I do to install the SQL driver for PHP 5.5 in Ubuntu.
My Server
PHP 5.5.9 on Ubuntu
SQL server 2012 on Microsoft server 2012R2
Below is the reference for connecting to a MSSQL Server database wtih LAMP.
Microsoft-SQL-Server-Database
Ubuntu Server – Connect to MSSQL via PHP
Its work on my PC.
Is there a way to connect to a Vertica database with PHP -- a function similar to mysql_connect()?
I'm ultimately trying to write a script that pulls data from a Vertica database and stores it in a localhost MySQL database.
If necessary, I would be willing to work with Python to make this happen.
The PHP ODBC module (classic or PDO) works fine for Vertica connections. You'll need to download the appropriate ODBC driver for your Vertica version from the My Vertica portal and install it on your PHP server.
Also you can use a Postgres client libraries to connect to Vertica instance.
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.