Setting up MSSQL configuration with PHP 5.6.x (XAMPP) and integrating it with CodeIgniter

Encountering an issue setting up MSSQL DATABASE configuration with my codeigniter. The following files have been placed in xamp/php/ext:

  1. php_pdo_sqlsrv_56_ts.dll
  2. php_sqlsrv_56_ts.dll
  3. php_sqlsrv_56_nts.dll
  4. php_pdo_sqlsrv_56_nts.dll

    In addition, the dll files have been extended in php.ini(both ts and nts were tested separately)

The database file in codeigniter is shown below

$db['default'] = array(
'dsn'   => '',
'hostname' => 'tcp:xyz.database.windows.net',
'username' => '****',
'password' => '****',
'database' => '****',
'dbdriver' => 'sqlsrv', // also tried mssql 
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

ERROR MESSAGE

Unable to establish a connection to the database server using the provided settings.

Filename: C:/xampp/htdocs/sqlsrv/system/database/DB_driver.php

Line Number: 436

Using PHP Version 5.6.14 in XAMPP environment.

Answer №1

In my opinion, utilizing a dsn is the optimal approach for this scenario. Given that you have already installed the PDO driver, you can experiment with the following configuration (assuming 1433 as the port - please verify your specific port):

$db['default'] = array(
    'dsn'   => 'sqlsrv:server=abc.database.windows.net,1433;Database=****',
    'hostname' => '',
    'username' => '****',
    'password' => '****',
    'dbdriver' => 'pdo', // I have also used mssql 
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Working with CodeIgniter and extracting data using an AJAX request

I've been experimenting with this code for a while now and I haven't been able to get it to work. I am working with CodeIgniter framework and when I click the button $('.galName').click(initUpdate);, it calls the following function: fu ...

What could be causing the issue with updating a js file using ajax?

I've been dealing with a php file called users. Initially, everything was going smoothly as I wrote some JavaScript code for it. However, after making updates to the JavaScript code, it seems to have stopped functioning. Below is the content of the p ...

An error was encountered: Attempting to access a method called sheetNameExists() within PHPExcel that is not

Can someone help me identify the source of this error that I'm encountering while trying to generate an excel file? Fatal error: Uncaught Error: Call to undefined method PHPExcel::sheetNameExists() in /public_html/docs/PHP/PHPExcel/Worksheet.ph ...

Challenges of implementing an infinite scroll feature using PHP, jQuery, MySQL, and AJAX

Hey there! I'm in the process of developing this website: It's almost complete, but I'm facing a challenge with the "Coleccion" section. In this section, users select a specific type of bag, and only 20 bags are initially loaded from a MySQ ...

Converting MySQL information into nested JSON format using PHP

I am in the process of extracting data from my database to a format compatible with a third-party service. It's quite simple to convert MySQL DB data into JSON. Below is a snippet I'm currently testing, although it doesn't encompass my entir ...

Retrieve the selected option from the user dropdown menu in PHP

How can I display a dropdown menu with the selected option for each user? User Table: ------------ id job 1 1 2 2 Job Table: ---------- id name 1 Doctor 2 Sales $q = $db->query("SELECT * FROM affiliate LEFT JOIN user ON user.job ...

Restrict the number of rows in a real-time search JSON data by utilizing the $.each method

Is there a way to limit the number of rows returned in live search JSON data through URL? I attempted to count the table rows and return false, but it did not work. Any suggestions on how to achieve this? $(document).ready(function() { $.ajaxSetup ...

Ajax issue: unable to retrieve $_SESSION data. Works on local environment but not on web server

I've been working on a website project that involves using jQuery to interact with a database. I store the user ID in a session for updating and deleting purposes. Everything seems to be running smoothly on my localhost (Wamp server), but when I uplo ...

Ordering Products in a Unique WooCommerce Shopify Theme

I'm encountering an issue with a purchased theme. I require the theme to arrange items in ASC order by date, similar to how woocommerce does it: [recent_products per_page="12" columns="4" orderby="date" order="asc"] However, this particular theme re ...

Is there a way to display a condition in Blade using jQuery through AJAX?

I am attempting to create a conditional statement using AJAX in my code that will display a button when the user is an 'admin'. While it is simple in Blade, I am encountering issues when trying to print it from jQuery. -- JavaScript Code -- cod ...

When the if-else statement is executed, it showcases two strings:

Learning Experience: Unveiling My Lack of Cleverness Update: It appears that utilizing PHP in my current setup is not possible. As a result, I'll take some time to contemplate while banging my head against a wall. Despite that, thank you all for your ...

Tips for leveraging dynamic user-agent header with PHP Curl or Guzzle Client

I am brand new to PHP and I am currently exploring how to call a REST Service. To achieve this, I have the option of using either Curl or Guzzle Client in PHP. After setting it up, I tested calling the service from Mozilla and Chrome Browsers. However, I ...

Steps to troubleshoot and resolve a bug that occurs after installing a module onto Magento 2

Upon installing the module "M2E Pro Amazon & eBay Integration", I encountered the following issue: composer require m2epro/magento2-extension:dev-master php bin/magento setup:upgrade An exception was thrown: [zzbusyco@nwpro5 public_html]S php bin/magent ...

Updating multiple rows in a table with Laravel

Currently, I am attempting to update the S_Rank column in all available rows within a table format. Each row displays information and includes a drop-down menu for changing the rank. My goal is to save these new rankings collectively. However, I have encou ...

Guide to securely encrypting passwords when transferring from an Android device to a PHP server

As a beginner in programming, I am currently working on a small application running on an Android device that requires user-based information from my PHP web server. My strategy involves using JSON for communication between the phone and the server. The p ...

Transmitting the identification number of a post with the help of J

I am currently working on a while loop in PHP that fetches associated results from a query and displays them within a class identified by the user who created the post. My goal is to send the id of the class to PHP, similar to how I am sending the num vari ...

Issue with parsing JSON data in jQuery Ajax requests

Trying to utilize php and jquery ajax with json datatype method for sending data. Check out the code below: $("#username").on("keyup change keypress", function () { var username = $("#username").val(); $.ajax ({ type: "POST", // method ...

Is there a way to choose an entire directory containing images using codeigniter?

For my current project, I am looking to choose an entire folder that contains pictures and apply a transformation to each picture within the folder. This process is akin to using scripts in Photoshop for making bulk adjustments to images. ...

Freeze your browser with an Ajax request to a specific URL

There is a function in my view that transfers a value from a text box to a table on the page. This function updates the URL and calls another function called update_verified_phone(). The update_verified_phone() function uses a model called user_info_model( ...

Update the form action URL when a specific option is selected from the dropdown menu upon clicking the submit

I would like my form to redirect to a specific page on my website based on the selection made in the <select> tag. For instance, if '2checkout' is selected, it should go to gateways/2checkout/2checkout.php. Similarly, if 'Payza' i ...