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

Call to undefined function sqlsrv_connect()

$
0
0

Hi, we are testing our sql connection thru php and coded 
<?php
$serverName = 'LAPTOP-B6LI2TEM';
$connectionInfo=array('Database'=>'MainEWALLET');

$conn = sqlsrv_connect( $serverName, $connectionInfo);
if($conn)
{
echo 'Connection established<br />';
}
else
{
echo'Connection failure<br />';
die(print_r(sqlsrv_errors(), true));

}
?>

but there is a fatal error of that goes ("Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\Login_v4\php\test.php:5 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Login_v4\php\test.php on line 5")

i already inserted the inserted the extensions php_pdo_sqlsrv.dll and php_sqlsrv.dll in the php.ini.

help pls

im trying to connect my sql server to php using xamp version 7.3.1

"Restricted data type attribute violation" error and SQLS 2017, ODBC Drivers 11 & 13

$
0
0
Dear all,

This issue occurs repeatedly with a table with columns that are somewhat managed dynamically in the sense that columns may be added or removed on occasion. The application attempts to bind with the table using a CRecordset class (dynamically bound). The issue is that this recordset class will fail to open the table with the error "Restricted data type attribute violation". This error will repeat twice in a row and then will not replicate again for a while. "A while" is an unknown length of time. While the time has not fully passed, the recordset will attach, open, and operate on this table like nothing is wrong. Once that time has passed "restricted data type attribute violation" error comes back. I have already attempted using different API conversions for dates.

Any help will be greatly appreciated...

Application framework: MFC/C++

SQL Server drivers tested/replicated:

- SQL Server 2017 (14.0.3049.1), OS - MS Windows Server 2016 Standard 64-bit

- Application Server OS Windows Server 2012R2 64-bit

- ODBC Driver for 11 for SQL Server

- ODBC Driver for 13 for SQL Server



Column types used:

- varchar

- datetime

- float

- int

Unable to load dynamic library

$
0
0

Hi,

I am getting the following error:

[14-Mar-2017 01:57:54 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Program Files\PHP\v7.1\ext\php_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
 in Unknown on line 0

But the file is there in the ext directory:
C:\Program Files\PHP\v7.1\ext\php_sqlsrv_7_nts_x64.dll

PHP Version 7.1.1
Drivers: SQLSRV40
Windows Server 2008 r2
IIS 7.5
MS SQL Server 2008 r2 Version 10.50.4000.0

Query doesn't show same results as in smss

$
0
0

Hello,

i've got the following environment: ubuntu18.04, apache 2.4, php 7.3, and the "PHP drivers Version 5.6.0 for SQL Server"

my sql query (it contains CTE's and union function) returns 1573 values.
The same query via my php script returns me 11 values ????

any ideas why?

this is my php mssql class

$serverName = 'tcp:'.$this::sql_server.','.$this::sql_port;
$connectionOptions = array("Uid"					=> $this::sql_user,"PWD"					=> $this::sql_pw,"ReturnDatesAsStrings"	=> true,"Encrypt"				=> true,"TrustServerCertificate"=> true,"LoginTimeout"			=> 15			
	);
$this->verbindung = sqlsrv_connect($serverName, $connectionOptions);



$query = sqlsrv_query($this->verbindung, $SQL);
$array = array();
while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){
	$array[] = $row;
}
sqlsrv_free_stmt($query);

Regards

Tobias

supplementing 1: I've created a view with the same code but i'm getting the same few resulsts

 supplementing 2: After some more testings, i think there are some issues with the sqlsrv driver from microsoft.
The same Query with pdo_sqlsrv is working and with sqlsrv not.

pdo_sqlsrv => all 1573 results
sqlsrv => 5

can someone confirm the problem?

Installing new driver on PHP for Windows

$
0
0

I am using PHP from the Windows command box.  I am able to call scripts just fine, but I need to call to odbc_connect or php_sqlsrv_connect.  But I continue to get a "Call to undefined function" error.  I have dropped this into both the PHP directory and even made an ODBC directory under \ext and init are the w4 files, etc.  I also dropped the DLL in there and also the PHP directory.  I have made sure the php.ini has the extension showing the right driver call (php_sqlsrv_73_ts_x64.dll).

What do I have to do to install this correctly?

Thanks in advance.

-- John

Error 1704 Microsoft SQL server 2008 R2 Native Client

$
0
0
Hello, I am attempting to install Tableau on my laptop and in the middle of the installation I receive an error 1704. An installation for Microsoft SQL server 2008 R2 Native Client is currently suspended. You must undo the changes made by the installation to continue. Do you want to undo those changes? When I select 'yes' nothing happens. What can be done in order for installation to work? I am using Windows 10 Version 1709 (2017).

SQL Server 2016 VMWare Windows 16 64bit - setup Oracle Driver

$
0
0

Hi,

New VMWare SQL Server 2016 Windows 16 64bit - setup Oracle Driver

Where can I find the Oracle driver for SQL2016?

How would I go about installing?

Please Help

Regards

Why can't Microsoft put the SQL Server Instance port number in the properties - General page in SSMS

$
0
0
Why can't Microsoft put the SQL Server Instance port number in the properties - General page in SSMS

integration of mysql server with php on IIS

$
0
0

Hello,

I have a php installed on iis servr on windows server 2012.. The php script has been executed successfully on the IIS erver . I want to integratie mysql server or sql server studio with the php script . i have installed both mysql server and sql server studion on the same server with iis.

I read an article that guided me on how to install mysql server community installer for php. I have created a database named 'student'. I created a user 'ict' and provisioned this user for this database. I equally granted  all the privileges for this user. I dont know if i did t correctly.

How can i verify the database connection in the php scritp ?

What if I do not rebuild my indexes?

$
0
0

Hi All,

we have a daily job to re-organize the table indexes and I have observed that the table fragmentation does not goes beyond 10%.

Do I still need to go ahead and re-index all the the indexes?  or I cancontinue whatever I am doing?


Regards, Ashif Shaikh



How do I use myPHP to access MySQL through PHPmyadmin?

$
0
0
I have my local site (Donor Management web page) hosted on my local server. I have myPHP installed in it to work with the SQL database through PHPmyadmin. But the myPHP is a really old version, how do I update it which has apache,php, MySQL as its components?

Exec as user/revert problem with ConnectionPooling

$
0
0

Try to connect and execute any statement with ConnectionPooling=1 is failed when previous connection used 'exec as user' without corresponding 'revert'.

Error message: HY000[0]: [Microsoft][ODBC Driver 11 for SQL Server]Unspecified error occurred on SQL Server. Connection may have been terminated by the server.

How to fix it? Of course, I'll use 'revert' at the end of user session, but in case of fault connection in pool will be broken for future use.

PHP 7.2, MS SQL 2005, PHP driver 7.2 ts 64bit.
Example code is attached.

<?php
  defined( 'ROOT_FOLDER' ) or define( "ROOT_FOLDER", str_replace("\\","/",dirname(__FILE__)));
  require_once( ROOT_FOLDER.'/Core/config.php' ); // User name and password file

  $handle = sqlsrv_connect( Config::server, array( "UID"=>Config::user, "PWD"=>Config::password, "Database"=>Config::database, "ConnectionPooling" => 1, 'ReturnDatesAsStrings'=> true, 'MultipleActiveResultSets' => true, 
'CharacterSet' => SQLSRV_ENC_CHAR, 'LoginTimeout' => 120, 'TraceOn' => false ) );
  if ($handle === false) die( "Connect error: ".GetLastError()."<br>" );
  ExecSQL( $handle, 'exec as user=\'nkolosov\';' );
  //ExecSQL( $handle, 'revert;' ); // With this - error will gone...
  sqlsrv_close( $handle );
  echo 'first ok<br>';
  $handle = sqlsrv_connect( Config::server, array( "UID"=>Config::user, "PWD"=>Config::password, "Database"=>Config::database, "ConnectionPooling" => 1, 'ReturnDatesAsStrings'=> true, 'MultipleActiveResultSets' => true, 
'CharacterSet' => SQLSRV_ENC_CHAR, 'LoginTimeout' => 120, 'TraceOn' => false ) );
  if ($handle === false) die( "Connect error: ".GetLastError()."<br>" );
  echo 'second connect ok<br>';
  ExecSQL( $handle, 'set ansi_padding on;' ); // <-- here is an error
  sqlsrv_close( $handle );

function ExecSQL( $handle, $stmt ) { 
  $res = sqlsrv_query( $handle, $stmt );     
  if ($res === false) echo "ExecSQL ($stmt): ".GetLastError()."<br>";
  $rows = sqlsrv_rows_affected ( $res );
  sqlsrv_free_stmt( $res );
}

function GetLastError() {
  if(($errors = sqlsrv_errors()) == null) return "";
  $err = "";
  foreach( $errors as $error) {
    $mess = $error[ 'message'];
    $err = $err.($err ? "::: " : "").$error[ 'SQLSTATE']."[".$error[ 'code']."]: ".$mess;
  }
  return "SQL error $err";
}
?>


Connection fails with 'Login failed for user xxx'

$
0
0

I'm trying to set up a demo on my local machine showing how to use SQLSRV in PHP. To facilitate, I've added a new login and a user using that login, both named DemoUser, and given that user db_datareader, db_datawriter and db_ddladmin roles for the example data I'm using (which is the Chinook database).

I also set SQL Server on the machine to use both Windows and SQL Server authentication and restarted the server.

With all that done, I can log in in SSMS as this user, and I can create a connection from Visual FoxPro (my usual dev tool) successfully using the SQLStringConnect() function. However, when I attempt to connect from PHP with sqlsrv_connect(), I get an error.

Here's the connection code:

  $hostname = "localhost";
  $username = 'DemoUser';
  $password = 'mYdemoUser';
  $database = 'chinook';
  $connectionInfo = array("Database"=>$database, "UID"=>$username, "PWD"=>$password, "CharacterSet"=>"UTF-8");
  $conn = sqlsrv_connect($hostname, $connectionInfo);

  if( $conn == false ) {
    echo "Connection could not be established.<br />";
    die( print_r( sqlsrv_errors(), true));
  }


and here's what I see:

Connection could not be established.Array
(
    [0] => Array
        (
            [0] => 28000
            [SQLSTATE] => 28000
            [1] => 18456
            [code] => 18456
            [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'DemoUser'.
            [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'DemoUser'.
        )

    [1] => Array
        (
            [0] => 28000
            [SQLSTATE] => 28000
            [1] => 18456
            [code] => 18456
            [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'DemoUser'.
            [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'DemoUser'.
        )

)
Any ideas what I'm missing?



Combining Laravel with SQL Server on Azure goes wrong...

$
0
0
I'm trying to deploy a Laravel Application to Azure using the App Service.

Things are working pretty ok, I set the PHP version to 7.1, added the Composer extention, and added a web.config file in the public folder of my repo for supporting rewrites in IIS. After that I deployed through Git. I also set the correct environmental variables.

The only problem is, I can't connect to the Azure SQL Database. It gives me this strange Protocol Error, which I can't solve. Google only shows old answers... I hope someone can help me?

```
SQLSTATE[HY000]: [Microsoft][ODBC Driver 13 for SQL Server]Protocol error in TDS stream (SQL: select * from [settings]) (View: D:\home\site\wwwroot\........\resources\views\login.blade.php)
```

Audit log

$
0
0
I would like to know how to enable audit logs for specific user group.

Ex:
If application development team do changes to live database without an approved change request form. So we suggested that audit logs should be enable in database server we need to track that whether they change the live data . However database admin says it is not possible. Is it true or any suggestion form your end.  

Access to all but one table

$
0
0

Hi is there a way where i can give access to a user to the whole database (READ ONLY) except for couple of tables?

Thanks

Back up process

$
0
0

Hi All,

I am planning to set backups for databases in simple recovery mode. Can anyone please provide me with some good document? Are there any other kind of backup's other than simple recovery? Which is the best and why?

Thanks

Error installing sqlsrv driver in Linux

$
0
0

When I try to install the driver in Ubuntu 16.04 I get the following error:

dtz-dany Install SQLSRV # pecl install sqlsrv
downloading sqlsrv-4.3.0.tgz ...
Starting to download sqlsrv-4.3.0.tgz (164,282 bytes)
....................................done: 164,282 bytes
33 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
building in /tmp/pear/temp/pear-build-rootKnDjzP/sqlsrv-4.3.0
running: /tmp/pear/temp/sqlsrv/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20151012
checking for PHP installed headers prefix... /usr/include/php/20151012
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable sqlsrv functions... yes, shared
checking for SQLSRV headers... /tmp/pear/temp/sqlsrv/shared/
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/tmp/pear/temp/pear-build-rootKnDjzP/sqlsrv-4.3.0':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
ERROR: `/tmp/pear/temp/sqlsrv/configure --with-php-config=/usr/bin/php-config' failed

I followed the Linux_4.0_Install_Instructions.pdf manual and the problem persists.

What I can do?

Thank you

Persistent VSS snapshot gets removed from restored VM

$
0
0

Persistent VSS snapshot is getting removed for some volumes on my VM on VMWare, below are the steps I used to do this

1] Take persistent VSS snapshot of SQL using SQl writer 

2] Take VM snapshot and backup  with one of the backup agents

3] Restore the same snapshot of VM

When I power on the restored VM the persistent VSS snapshot I took before backup gets removed for one of the volumes for others it is still there as expected.

I have faced this issue very rarely, I use this method to take backups regularly but it has failed with this error only 3 times out of 1000.

Earlier I thought this was due to system drive but it has happened on other drives as well

Sql Server Native client for Mac

$
0
0

Hello,

First I hope that I'm in the right forum.

I'm using Excel VBA (PC) and SQL Server, in the past I needed to installed SQL Server Native Client to be able to do it, and after I installed it, everything is working good.

Now I want to be able to do the same thing with Excel for Mac and contact Sql Server.

I searched the web and find this page but i dont know what to download from there (too many options)

https://docs.microsoft.com/he-il/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver15

Can someone please guid me what should I install to be able to do it.

Thank you

Viewing all 391 articles
Browse latest View live


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