sqlsrv

Connecting php 7.2 to MS SQL using sqlsrv

不想你离开。 提交于 2019-12-04 04:35:54
I'm trying to get a connection to MS SQL up and running via PHP on my machine. I'm running IIS, have PHP 7.2 installed and MS SQL Express 2017. I have my basic web page running but when I click to open the PHP page, the connection does not work. session_start(); echo "Hello "; if (isset($_POST['submit'])) { $_SESSION["server"] = $_POST['server']; $_SESSION["database"]= $_POST['database']; $_SESSION["username"] = $_POST['username']; $_SESSION["password"] = $_POST['password']; echo $_SESSION["database"]; //CONNECTION $serverName = $_SESSION["server"]; $connectionInfo["Database"] = $_SESSION[

Connecting to SQL Server via CodeIgniter

六月ゝ 毕业季﹏ 提交于 2019-12-03 16:21:30
I'm trying to setup a Windows dev environment: Windows 8.1 with IIS 8.5 running SQL Server 2008RC2 and PHP 5.3.24 CodeIgniter 2.1.4 I can connect to the database just fine via PDO in a normal PHP script. But when I try to connect via CodeIgniter I get this error: "Unable to connect to your database server using the provided settings. Filename: C\inetpub\wwwroot\ci\system\database\DB_Driver.php Line number 124" If I open PHP Manager in the IIS interface I can see that the two required drivers are enabled: php_sqlsrv_53_ts.dll php_pdo_sqlsrv_53_ts.dll Both of those show up in my ini file. In my

INSERT several rows with a prepared statement in a loop

冷暖自知 提交于 2019-12-02 23:37:21
问题 Sqlserv php error when inserting using array portion ARRAY PREPRATION foreach ($data as $rs) { $params []="({$rs->hd},'{$rs->dvn}',{$rs->mth},{$rs->yr},{$rs->stid},{$rs->prcd},'{$rs->prnm}',{$rs->prte},{$rs->ssl},{$rs->clsk},1)"; } INSERT INTO STATEMENT: $SqlInsert="insert into SQl_test (Ss_Hq_cd,Ss_division,Ss_month,Ss_yr,Ss_stk_Id,Ss_prod_cod,Ss_prod_name,ss_prod_rate,Ss_Sale,Ss_Cl_stk,ss_tran_stat) values(?,?,?,?,?,?,?,?,?,?,?) "; $stmt = sqlsrv_query( $conn, $SqlInsert,$params); EROOR:

SQLSRV PHP for SQL Server for is not a valid Win32 application

拜拜、爱过 提交于 2019-12-02 22:57:18
Here is my setup Windows Server 2008 R2 64 bit Apache 2.4.4 64 bit PHP 5.4.15 32 bit (64 bit is still experimental), thread safe, VC9 compiler Microsoft SQL Server 2012 Native Client 64-bit Microsoft Visual C++ 2010 x86 and x64 I need to load Microsoft's SQLSRV library. I have added 'extension=php_sqlsrv_54_ts.dll' to php.ini and copied 'php_sqlsrv_54_ts.dll' to the ext folder where PHP is installed. When I restart apache, I get the following error in my php error log, and SQLSRV is not listed in phpinfo. PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php5\ext\php_sqlsrv_54_ts

PHP Get return value from MSSQL Stored Procedure

风格不统一 提交于 2019-12-02 15:59:20
问题 I can't get the OUTPUT parameter from my SQL Server (MSSQL 2012) SP to return to PHP. My Stored procedure is: CREATE PROCEDURE spGetNextSeqID @ID AS INT OUTPUT AS BEGIN BEGIN TRANSACTION SELECT @ID = SEQUENCE_NO + 1 FROM tblCSRSequence WITH (TABLOCKX) UPDATE tblCSRSequence SET SEQUENCE_NO=@ID COMMIT TRANSACTION END And my PHP code is:- <?php include "DBConnect.php"; $conn = sqlsrv_connect( $serverName, $connection); if( !$conn ) { echo "Connection could not be established to ".$serverName;

INSERT several rows with a prepared statement in a loop

冷暖自知 提交于 2019-12-02 14:23:57
Sqlserv php error when inserting using array portion ARRAY PREPRATION foreach ($data as $rs) { $params []="({$rs->hd},'{$rs->dvn}',{$rs->mth},{$rs->yr},{$rs->stid},{$rs->prcd},'{$rs->prnm}',{$rs->prte},{$rs->ssl},{$rs->clsk},1)"; } INSERT INTO STATEMENT: $SqlInsert="insert into SQl_test (Ss_Hq_cd,Ss_division,Ss_month,Ss_yr,Ss_stk_Id,Ss_prod_cod,Ss_prod_name,ss_prod_rate,Ss_Sale,Ss_Cl_stk,ss_tran_stat) values(?,?,?,?,?,?,?,?,?,?,?) "; $stmt = sqlsrv_query( $conn, $SqlInsert,$params); EROOR: Error in statement preparation/execution.\n" Array ( [0] => Array ( [0] => 22018 [SQLSTATE] => 22018 [1]

Driver for sqlsrv 4.0 doesn't apper on phpinfo()

泪湿孤枕 提交于 2019-12-02 11:06:19
I need help with Microsoft driver for mssql 4.0. I use php 7.1 , win'2012 x64 , mssql 2008 R2 and installed odbc driver 13 as it is described in documentation and copyed all dlls in ext folder. In php.ini I added: extension_dir = "c:\inetpub\php\ext" extension=php_sqlsrv_7_nts_x64.dll Restarted IIS. And still after calling phpinfo() I can't see sqlsrv. Maybe I missed something in php.ini? After looking through some of the issues posted on GitHub it appears that the drivers supplied from the Microsoft website are currently incompatible with PHP 7.1, despite the System Requirements on the page

PHP Get return value from MSSQL Stored Procedure

微笑、不失礼 提交于 2019-12-02 09:06:16
I can't get the OUTPUT parameter from my SQL Server (MSSQL 2012) SP to return to PHP. My Stored procedure is: CREATE PROCEDURE spGetNextSeqID @ID AS INT OUTPUT AS BEGIN BEGIN TRANSACTION SELECT @ID = SEQUENCE_NO + 1 FROM tblCSRSequence WITH (TABLOCKX) UPDATE tblCSRSequence SET SEQUENCE_NO=@ID COMMIT TRANSACTION END And my PHP code is:- <?php include "DBConnect.php"; $conn = sqlsrv_connect( $serverName, $connection); if( !$conn ) { echo "Connection could not be established to ".$serverName; die( print_r( sqlsrv_errors(), true)); } $sql="{call dbo.spGetNextSeqID( ? )}"; $outSeq=0; $params =

Call to undefined function sqlsrv_connect() - Troubleshooting

我与影子孤独终老i 提交于 2019-12-01 23:52:09
System Information CMS: Wordpress Web Server: XAMPP PHP Version: 5.5.30 MS Management Studio 17 Goal Establish MSSQL Database connection using PHP What has been done Downloaded SQLSRV Drivers Copied files php_pdo_sqlsrv_55_nts.dll and php_pdo_sqlsrv_55_ts.dll to the directory C:\xampp\php\ext Added the following lines to the dynamic extensions part in the php.ini file: extension=php_pdo_sqlsrv_55_ts.dll and extension=php_pdo_sqlsrv_55_nts.dll Restarted Web Server Confirmed sqlsrv is listed in phpinfo() Code $serverName = "technology-pc\sqlexpress"; // The connection will be attempted using

Issue executing stored procedure from PHP to a Microsoft SQL SERVER

风流意气都作罢 提交于 2019-12-01 21:00:41
I am using the code igniter framework. And I been trying to execute a stored procedure(no params) I wrote on Microsoft SQL Server 2008 from PHP but i get an error . This stored procedure runs good on Microsoft SQL Server with no errors. I am using sqlsrv as the driver and I have a PHP version 5.2 if that helps. This is the error I get Error Number: 01000 [Microsoft][SQL Server Native Client 10.0][SQL Server]Executing SQL directly; no cursor Exec sp_test The following is part of the code I have function index(){ $this->load->database(); $query=$this->db->query("Exec sp_test"); var_dump($query-