Codeigniter 3 + php 5.6 + xampp + sqlserver 2008 + win7 64x - php

So sorry if this exists, but I'm having trouble with codeigniter 3, php 5.6, sqlserver 2008 and win7 64x.
I followed the steps from various sites, such as Rob's Area, also read a couple of questions in this site but still can't find the answer.
With php_pdo_sqlsrv_56_ts.dll and php_sqlsrv_56_ts.dll from SQLSRV32.EXE the error I was getting was:
Unable to connect to your database server using the provided settings.
Filename: C:/xampp/htdocs/mycodeigniter/system/database/DB_driver.php
Line Number: 436
Then downloaded Rob's sqlsrv_unofficial_3.0.2.2.zip and got this error:
Message: Call to undefined function sqlsrv_connect()
Filename: sqlsrv/sqlsrv_driver.php Line Number: 144
The code I have in Codeigniter is:
$db['default'] = array(
'dsn' => '',
'port' => '1433',
'hostname' => '127.0.0.1',
'username' => 'myuser',
'password' => 'mypass',
'database' => 'mydb',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'autoinit' => TRUE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
Then used this one, this one worked, but can't call the results when querying.
$db['default'] = array(
'dsn' => 'Driver={SQL Server Native Client 10.0};Server=127.0.0.1;Database=mydb;',
'hostname' => '',
'username' => 'myuser',
'password' => 'mypass',
'database' => 'mydb',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
Please ideas?

Take the php_pdo_sqlsrv_56_ts.dll (afaik the current sqlsrv build should be ok, otherwise you've to take robs build)
After that try the following in your db-config
$db['default'] = array
(
'dsn' => 'sqlsrv:server=127.0.0.1,1433;Database=mydb',
'username' => 'myuser',
'password' => 'mypass',
'dbdriver' => 'pdo',
...
);
1433 is the current port - change it to your defined port - but i'm not sure if you need that

Related

Undefined function mssql_connect() Codeigniter 3.0 + Azure Database + 000webhost + PHP 5.6

I'm using Codeigniter 3.0 on 000webhost (PHP 5.6) and trying to connect to a database on microsoft azure.
I have the following configuration for my database.php file:
$db['default'] = array(
'dsn' => '',
'hostname' => 'xxxx.database.windows.net',
'port' => '1433',
'username' => 'abcd',
'password' => '*****',
'database' => 'mydb',
'dbdriver' => '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
);
I'm getting the following error:
I tried changing the dbdriver to sqlsrv. However, I get the same error except now it complains that sqlsrv_connect() is undefined.
PHP info is given below:
PHP INFO OUTPUT
Try with this,
The setting in application\config\database.php should be like:
'hostname' => '<server_name>.database.windows.net,1433',
'username' => '<username>',
'password' => '<password>',
'database' => '<database>',
'dbdriver' => 'sqlsrv',
'pconnect' => FALSE,
Azure doesn't install php_mssql.dll automatically,but it installs php_sqlsrv.dll
So tyr with above.
try this as per your phpinfo mysqli is installed
'dbdriver' => 'mysqli',

Unable to connect using PHP 7.2.4 with SQL Server 2008

I have newly installed PHP 7.2.4 and Apache 2.4 on windows server 2008 r2. Everything done; i have set the paths, but problem is that when i configuring my PHP file for the connection, it gives me an error unable to connect with database. I am using codeIgniter 3.1.8.
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'database_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE
)
define('ENVIRONMENT','development'); This is a Codeigniter 3, database.php (non SSPI) snippet example for MSSQL 2008R2:
define('ENVIRONMENT','development');
$db['test1'] = array( 'dsn' => '',
'hostname' => 'MY_MSSQL_DB_FQDN\i1,10001',
'username' => 'somemssqluser',
'password' => 'somemssqlpassword',
'database' => 'somedbname',
'dbdriver' => 'sqlsrv',
'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
);

configuration MSSQL with PHP 5.6.x(xamp) using code-igniter

I have an issue while configuration MSSQL DATABASE with my codeigniter. I have placed these below file in xamp/php/ext:
php_pdo_sqlsrv_56_ts.dll
php_sqlsrv_56_ts.dll
php_sqlsrv_56_nts.dll
php_pdo_sqlsrv_56_nts.dll
I have also ensured to extended dll files in php.ini(I have tested both ts and nts separately)
Below is my database file in codeigniter
$db['default'] = array(
'dsn' => '',
'hostname' => 'tcp:xyz.database.windows.net',
'username' => '****',
'password' => '****',
'database' => '****',
'dbdriver' => 'sqlsrv', // i have use also 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
Unable to connect to your database server using the provided settings.
Filename: C:/xampp/htdocs/sqlsrv/system/database/DB_driver.php
Line Number: 436
I am using PHP Version 5.6.14 in XAMP .
imho you should use a dsn for this - since you also installed the pdo driver you can try the following (1433 is the port - i don't know yours):
$db['default'] = array(
'dsn' => 'sqlsrv:server=xyz.database.windows.net,1433;Database=****',
'hostname' => '',
'username' => '****',
'password' => '****',
'dbdriver' => 'pdo', // i have use also 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
);

Codeigniter + Lampstack - Unable to connect to your database

i have this on my localhost and it works perfectly fine.
but when i put it on a server i configured the database settings correctly
here is my config/database.php
$db['default'] = array(
'dsn' => '',
'hostname' => '111.111.1.111', //sample host
'username' => 'root',
'password' => 'password',
'database' => 'mydatabase',
'dbdriver' => 'mysqli',
'port' => '1234',
'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' => FALSE
);
but all i got was the error
Unable to connect to your database server using the provided settings.
Filename: third_party/MX/Base.php
Line Number: 55
what is the problem?

codeigniter 3 error connecting to db

I run wamp and try to connect to db but I got
Unable to connect to your database server using the provided settings.
Few faqs / what I've done:
I autoloaded the database library in config.php
my phpMyAdmin doesn't have any username and pass set
this is the setting in database.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => 'ciintro',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE,
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
'username' => '',
should be
'username' => 'root',
check username.
I think you are newer to codeigniter.
'username' => 'root' ( root or whatever you set for PHPMYADMIN.)
'password' => 'password' ( password or whatever you set for PHPMYADMIN.)

Categories