Quantcast
Channel: Microsoft Drivers for PHP for SQL Server forum
Viewing all 163 articles
Browse latest View live

Sql Server

$
0
0

This application, “eChamber”, uses a framework that is based on the ORM for PHP: doctrine 1.2.6 inspired by nHibernate. Furthermore, the framework is only compatible with php 5.3 and higher. When used with Oracle and MySQL, the application faces no problem and we are able to switch seamlessly from one RBDMS to another.

But when we have tried to switch to SQL Server 2008 nothing works. We are facing a lot of issues, themost important are:

  • Doctrine 1.2.6 doesn´t support the new Microsoft Driver and PHP 5.3 doesn´t support the old driver (mssql) any more.
  • We haven´t been able to run the doctrine functions: build task with our existing object models
  • We haven´t been able to execute complex SQL queries: as double left join, renaming results, etc.
  • Problems using UTF-8 encoding on data. The data loaded from Web Application is encoded incorrectly when loaded to the database. This is because the whole application is encoded in UTF-8 and the database Ms-SQL is expecting UCS-2. Indeed for ‘nvarchar’ types, Ms-SQL Server always uses UCS-2 encoding to store the data no matter which collation we use.

 

None of ourworkaround solutions worked inspired by Ms kb-232580:

1-    Using PHP 5.3.x and new driver: not working namely, Ms-SQL database is not reachable for our new application.

 

2-    Using PHP 5.3.x and ODBC has 2 issues :

  • Too frequently we have the following error:

SQLSTATE[25000]: Invalid transaction state: 3902 [Microsoft][ODBC SQL Server Driver][SQL Server]The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. (SQLExecDirect[3902] at ext\pdo_odbc\odbc_driver.c:247)

The workaround would be to manually simplify the queries. However, this is an inconvenience, to say the least, because we have a lot of complex queries. Furthermore, we think it is inacceptable to overcome this issue with changes in php code and object models.

  • Application collation (UTF8) vs Ms-SQL collation (UCS-2): Application must use UTF8 encoding for these reasons: framework UTF8 full compatible (i18n, pdf generator, xml exchange, ORM …), bank exchange must be in utf8. But Ms-SQL doesn’t support UTF8 encoding for Unicode data, Arabic in our case. Since we are using a Framework and an ORM, no collation conversion can be done: neither on apache side when sending form (via GET or POST), nor before displaying these data (like using <% Session.Codepage=65001 %>).

 

3-    Using PHP 5.2.11 and old driver (mssql) has at least 2 critical non-working library:

  • Security module (login/password),
  • Quotation and billing modules,
  • Etc.

 

Consequently, we are looking for a solution to handle easily and seamlessly UTF8 data (and more especially Arabic letter) with Microsoft Ms-SQL server 2008 R2 and we would appreciate your suggestions to address the issues mentioned above.




Get num rows with Stored Procedures

$
0
0

PHP 5.4.9
SQL SERVER: 2008 R2
DRIVER FOR PHP FOR SQL SERVER: 3.0.1

I was using php 5.2 so I was still using the driver mssql. Now I am trying to update my system and I can not make sqlsrv_num_rows work when I query a store procedure.

Example:

$sql="prueba";
$params = array();
$options =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$query =  sqlsrv_query($conexion, $sql, $params, $options);
echo "-". sqlsrv_num_rows($query);

It shows -1

I can not believe there is not a way to do this being in the version 3.0.1 of the driver when mssql had it.

Retrieving and displaying images

$
0
0

Hi,

I have to display images from a mssql databse using PHP and the SQLSRV driver. The images are saved in an image type column as binary. I have been searching for days trying to figure this out. I have the following test code but it is not working. I only get a single image.

Does anyone know how to do this?

$dbHost = '***';
$dbName = '***';
$dbUser = '***';
$dbPass = '***';

$serverName = $dbHost;
$connectionInfo = array("Database"=>$dbName, "UID"=>$dbUser, "PWD"=>$dbPass);
$conn = sqlsrv_connect($serverName, $connectionInfo);

$sql = "SELECT TOP 5 DocMgtImageID, ImageData FROM tbDocMgtImages";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
    die( print_r( sqlsrv_errors(), true) );
}

while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
	header("Content-type: image/jpeg");
	echo $row['ImageData'];
}

sqlsrv_free_stmt( $stmt);

Thank you!


"Severe error translating Unicode" when calling sqlsrv_fetch_array on a query with buffered cursor and empty nvarchar result

$
0
0

Hi,

This is a problem I'm having in SQL Server 2008 R2 (on Windows Server 2008 R2 Enterprise). I'm using SQLSRV 3.0 and SQL Server 2012 Native Client. This is how you can (probably) reproduce the problem:

1. Create a table which has at least one nvarchar field. In my case, the DB collation is Arabic_CI_AS, although I don't know if it matters.

2. Insert at least one record in the table, in which the nvarchar field is assigned the empty string value (not NULL).

3. Execute a query using sqlsrv_query on the table which should return at least the nvarchar field of the above record. Specify buffered cursor when calling the query.

4. The query executes without any problem, but trying to fetch the row with empty nvarchar string using sqlsrv_fetch_array results in a fatal error which says "Severe error translating Unicode in <filename>".

Sorry if this should not have been reported here, I was not sure. Is this really a bug? Should I add it to the issue tracker?

This problem can apparently be worked around by converting empty nvarchar values to NULL or something else, by converting the nvarchar type to something else, or by using some server-side cursor type.

Stop words (Noise words)

$
0
0

I am trying to do a query but I get the next error:

[Microsoft][SQL Server Native Client 11.0][SQL Server]Información: la 
condición de búsqueda de texto completo contenía palabras irrelevantes.

Which means something like:

The full-text search had stop words

When I execute the select on the sql server management studio, I don't get that error, only when I execute it from the driver for php.

It is a really easy query:

$query = "select * from table where contains (*,'?')";
$params = array('java and php');

I use sql server 2008 R2


PHP for SQL Server Driver on separate machine as SQL Server

$
0
0

Hello,

Is it possible to install the MS Drivers for PHP for SQL Server on a different machine from SQL Server?  I am installing Drupal and have to use SQL Server Enterprise.  Well the Enterprise is not on the same machine as Drupal. 

I ask this because in the help section of the driver, it seems to say that both need to be on the same machine.  I don't have that setup available to me.

So is it possible to have them separate?

Connecting to SQL Server 2000 with PDO drivers

$
0
0
I read that the PHP PDO drivers use the SQL Server 2012 Native Client ODBC Driver to connect to SQL Server. The SQL Server 2012 Native Client says it supports connecting to SQL Server 2000, but the PHP PDO drivers say that it's for 2005 and higher. Does that mean I can use the PHP PDO 3.0 drivers to connect to SQL Server 2000 afterall?


stored procedure from SQL Server in PHP

$
0
0

I need help running a stored procedure from SQL Server in PHP. PHP is running on a Unix/Linux server. We cannot get OUTPUT variables to return in PHP. The following is the PHP code:

$conn = mssql_connect('server','user','pass');
    mssql_select_db('db', $conn);

    $procedure = mssql_init('usp_StoredProc', $conn);

    $tmpVar1 ='value';
    $tmpVar2 ='value2';

    $outVar1 ='';
    $outVar2 ='';

    mssql_bind($procedure,"@var1", $tmpVar1, SQLVARCHAR,false,false);
    mssql_bind($procedure,"@var2", $tmpVar2, SQLVARCHAR,false,false);

    mssql_bind($procedure,"@outVar1", $outVar1, SQLVARCHAR,true);
    mssql_bind($procedure,"@outVar2", $outVar2, SQLVARCHAR,true);

    mssql_execute($procedure,$conn);print($outVar1);print($outVar2);

The stored procedure looks like so :

    SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER proc [dbo].[usp_StoredProc](@var1as varchar(36),@var2as varchar(10),@outVar1 varchar(36) OUTPUT,@outVar2 varchar(36) OUTPUT )asselect distinct @outVar1= row1,@outVar2= row2from table1where column1 =@var1and column2 =@var2

Can anyone tell me why $outVar1 and $outVar2 are not being populated? Thanks a lot for any help!



Can't figure out how to install sql server for PHP

$
0
0

I am trying to install SQL Server for PHP on a server with Server 2008 32 bit.  The exe from http://www.microsoft.com/en-us/download/details.aspx?id=20098 keeps tell me that it is an invalid win32 application.  I've tried running as administrator as well.  Somewhere I read you need to open the exe with 7zip.  I was able to do that and see all the files in there, but where do I go from there?

Thanks

Mike


edit: forgot to mention I'm using Apache for my server

Unable to Generate SSPI Context sql 2008 R2

$
0
0

HI,

We have SQL 2008 R2 on cluster with instances configured on it. When we are trying to make a connection with ODBC (System DSN) to one of the instance , it gives an error "Cannot Generate SSPI context.

We checked below settings.

1. DNS entry is correct , able to do nslookup to db.

2. Refered the url http://support.microsoft.com/kb/811889 perform all activity as described but no resolution.

3. Checked date and time on both the server.

Please let me know what else need to be checked. From the same machine we are able to connect to other instance.

Installing MS SQL PHP drivers under Windows 2008 Server

$
0
0

Hi All,

We are trying to setup MS SQL Server access from PHP 5.4 under Apache 2.2. The host is a Windows Server 2008 SP2 Enterprise. We downloaded the drivers from http://www.microsoft.com/en-us/download/details.aspx?id=20098 (file SQLSRV30.EXE).

When we run the installer, no matter what target folder we select, we get this error message:

"That folder is invalid. Please make sure the folder exists and is writable"

Can anybody provide any hint on this? Or at least point us to a compressed file to extract the right files from. Thank you very much in advance.

Edo.

Problem in creating odbc driver data source

$
0
0

Hi, I have problem in creating data source ODBC driver in SQL server 2008R2 express edition,after i clicked finished and test connection.this is the error that will produce.

Microsoft SQL Server Native Client Version 10.50.1600

Running connectivity tests...

Attempting connection
[Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2].
[Microsoft][SQL Server Native Client 10.0]Login timeout expired
[Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

TESTS FAILED!

I also checked in the SQL server Configuration Manager but i found this error in SQL server services

The remote procedure cal failed.[0x800706be]

Can you please help me on this.

Thank you in advance.

PHP 5.3.9 not updating mssql drivers IIs Windows 2008 R2 server

$
0
0

I am running PHP 5.3.9 on Windows Server 2008 R2 using IIS.

I have installed the drivers from SQLSRV30.EXE into the PHP\ext directory on the server

I have installed the SQL native client on the server

I have changed php.ini to the following:

[PHP_SQLSRV]

extension=C:\PHP\ext\php_sqlsrv_53.nts.dll

I have restarted the server after making the change.  I get the following error message when calling the function:

Call to undefined function sqlsrv_connect()

When I open PHPinfo, it states "mssql-without'.  What did I miss here?


PHP -> MSSQL very slow when the DB is not on the same machine as the PHP code

$
0
0

In the course of trying to move our website to Azure, we've found a problem with our PHP code talking to MSSQL.

On the current dedicated host (hosting both the PHP and the DB), going to a page typically takes less than 2 seconds. I've also run the queries necessary through SMS and they take less than 1 second.

With the website hosted on Azure (connecting to an Azure SQL database) the same page takes around 40 seconds to load. Further investigation showed that this might be caused by the database not being on the same machine as the PHP - when the original website is pointed at a remote database (either another dedicated machine or the Azure SQL instance) the page load time goes up into the 40 second range.

The current webhosting machine is running PHP 5.4 and Microsoft SQL Server Express Edition.

The Azure website is running on PHP 5.4.

In both cases we're using the 3.0.1 Microsoft SQLSRV drivers 

How can we improve the performance when connecting to a remote SQL DB?

Thanks,

James.

Connection to SQL Server 2008 - Login failed for user

$
0
0

Hi

I have setup a PHP webpage and am trying to connect to an SQL Server 2008 on another machine.

I have installed 'Microsoft Drivers for PHP for SQL Server' on my local machine which also has WAMP installed with PHP version 5.3.5.

I am getting the following error:

array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'DOMAIN\Ryans'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'DOMAIN\Ryans'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'DOMAIN\Ryans'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'DOMAIN\Ryans'. ) )'

I have setup the user under security - logins on the server.

The code i am using to connect to the server is -

$serverName = "crm\MSSQLSERVER,1433";


$connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=> $servername);
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn )
{
     echo "Connection established.\n";
}
else
{
     echo "Connection could not be established.\n";
     die( print_r( sqlsrv_errors(), true));
}


Any help would be much appreciated.

Regards Ryan


SQLSTATE[IMSSP]: This extension requires the Microsoft SQL Server 2012 Native Client ODBC Driver to communicate with SQL Server

$
0
0

I am using mysql and PHP5.3.19 on Windows 2008 Server R2 Sp1. I.

PHP 5.3.19 is installed using IIS 6.0. But when I try to connect to a SQL Server database I get this error

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: This extension requires the Microsoft SQL Server 2012 Native Client ODBC Driver to communicate with SQL Server. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712' in

I have followed the instructions and downloaded the Microsoft SQL Server 2012 Native Client ODBC Driver and installed it on my server but It is not working. I still get the same error.  What can I do here? Is there a way To validate thatMicrosoft SQL Server 2012 Native Client ODBC Driver is installed correctly? What Can I do? I have wasted all my day trying to fix this issue.

Thanks

SQL Server 2008 R2 does not replay

$
0
0

Hi,

I have updated my system from PHP 5.2.6 to 5.4.13 and it works. (I used to use mssql driver and I'm using sqlsrv driver now).

The thing is that sometimes, SQL server 2008 R2 does not answer.

The PHP script keeps running waiting for an answer, and if I am on the SQL Server management studio, it pushes me out.

I do not know what can if be, but I switched the PHP version on the IIS to start working with mssql driver again and it works fine.

Any help? Thanks.

sqlsrv configuration

$
0
0
hi some body learn me how to config php and sqlsrv with iis in windows 7 64 bit 

How can I install SQL SERV 3.0 for PHP 5.4 on Windows XP SP3 ??

$
0
0
I want install SQLSERV3.0.EXE for PHP 5.4 on windows XP SP 3 but it's give an error

"not a valid win32 Application"

Any solutions ?

Thanks before..

*HI*

$
0
0

Hi everyone

I am new to this community and I just started learning BI tools.Can any one plz explain me clearly the difference between ssrs and ssas?After extracting the packages in ssis.Should  I use reporting services or cube to generate a report?If possible could anyone provide me with a sample example?.

Thanking you in advance.

SANY

Viewing all 163 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>