• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter and MS SQL Database

#1
Hi,

I'm learning PHP and CodeIgniter framework was highly recommended. I've been search the web for example and tip on how to connect CodeIgniter and MS SQL 2014. Sadly, I had no luck. This is my development setup:
  • IIS 7
  • PHP 7.1.21
  • MS SQL 2014
my database.php


Code:
$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'hostname' => '127.0.0.1',
    'username' => 'web_user',
    'password' => 'password',
    'database' => 'blogOne',
    'dbdriver' => 'mysqli',
    '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
);


I'm getting the following error:


Quote:A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.
Filename: mysqli/mysqli_driver.php
Line Number: 201
Backtrace:
File: C:\inetpub\wwwroot\CITA-PHP\index.php
Line: 315
Function: require_once

thank you in advance for your help!
Reply

#2
You must use the sqldrv driver not the mysqli.
And if you use the express edition don't for get the \SQLEXPRESS in the hostname.
Also I see not the port 1433 in the config.

Goodluck

Andre
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme ¬© 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.