Access MS SQL from Php 5.5 - php

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.

Related

Connection doesn't established when connect to sql server via php

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?

Connect to SQL Server using PHP in MacOs Sierra : Could not find driver

I have an app written in PHP that connects to MySQL. One of my customers want to use SQL Server instead. In the past i had a big headache to make PDO connect to SQL Server in a Windows 2008 machine, but now i'm on a Mac with Sierra. Is there any 'easy' way to configure this connection, without having to download sources, compile and so on ?
By simply using the code below :
$dbh = new PDO("sqlsrv:Server=dbserver.domein.com;Database=testdb", "User#dbserver", "Password");
I get the 'Could not find driver' error.
Thanks !
Making a connection with PDO to an SQL Serve shouldn't be a problem.
$dbh = new PDO("sqlsrv:Server=dbserver.domein.com;Database=testdb", "User#dbserver", "Password");
However you should check the query's for some DB Server specific query's.
While they are both SQL there are still some differences between the two.

PHP Unable to connect to MS SQL server

I have used default MS SQL driver to connect to a SQL server in a php application.
I'm using XAMPP 1.6.8. my php version is 5.2.6.
Application was connected successfully to the SQL server and the application was running successfully for a long time. Now suddenly the application is showing an error on mssql_connect() function with same MS SQL access information.
the error is "Unable to connect to server: xxx.xxx.xxx.xxx"
I also checked the SQL server access info with a SQL client. SQL client can connect successfully, therefore i think the access info is correct.
Can any one help me resolved this issue?
Thx
I just found my solution here. http://jimmyli.net/2009/03/php-unable-to-connect-to-mssql/ .problem was that the file ntwdblib.dll packaged with PHP5 was an old version. then i just replace with updated one from here http://jimmyli.net/wp/wp-content/uploads/2009/03/ntwdblib.zip
Thx

mssql_connect slow (linux server)

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

mssql_connect on Linux server with PHP 5.3

I know that mssql_connect will not work on windows server with PHP 5.3 or later, but will it work on Linux?
mssql_connect = Connect to a MS SQL Server
mysql_connect = Connect to a MySQL Server (open source database server) usually on linux
You can get MySQL on windows platforms

Categories