Database error on uploading website designed using codeigniter - database

I have been working on a cms based website. But now that its time to upload it shows a database error
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
I have checked my database.php file located in applications/config
Its contents:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'xy.in';
$db['default']['username'] = 'xy_eta';
$db['default']['password'] = '';
$db['default']['database'] = 'xy_livefiesta';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
I am sure about the database name and the username
BUt not sure about the hostname(thts the same as the first domain that i purchased while buying a shared hosting)
Please help me out in finding the error

Web services do not allow you to have databases without a strong password.
You need to login with the administrator privilidge and set a password for the database and also set the password in the config/database.php file too.

Are you sure your hostname is correct? Try changing it to localhost

Related

Unable to connect to your database server using the provided settings in CI

A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: /home/rehmantr/public_html/third_party/MX/Loader.php
Line Number: 94
Dear Sir,
I am facing this issue, my database.php file setting is below
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'hostname';
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'database';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
but still I am facing this issue,please help me.
I am using HMVC pattern of CI
I think its a problem with your credentials, verify that user and password are correct and that the user has access to the database you specify in the settings.

how do I connect codeigniter to a SQL server?

I've seen a lot of posts but none that actually worked. Can someone provide a clean/clear way to connect Codeigniter with a MS SQL Server on a Mac? This is high level but I have yet to see a solution that clearly demonstrates this. Thanks a bunch!
I have already done this, in your application/config/database.php put the following:
// This address is valid if you're on the same domain as the server:
// If not, you can put the ip address or url here as well.
$db['default']['hostname'] = 'DBComputerName\SQLEXPRESS';
// if you need a non default port uncomment and edit
//$db['default']['port'] = '5432';
$db['default']['username'] = 'databaseUsername';
$db['default']['password'] = 'databasePassword';
$db['default']['database'] = 'DatabaseName';
$db['default']['dbdriver'] = 'sqlsrv';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
I know how frustrating this was, as a word of caution, not all Active Record functions work or work as expected, this is due to many SQL server quirks.
I recommend switching most of your Active Record queries to: $this->db->query();
PS If I remember correctly, MSSQL doesn't have a username preconfigured, you need to create a username and allow db access from outside of the subnet.
Refer to this in order to create the db user:
http://technet.microsoft.com/en-us/library/aa337545.aspx
and allow access:
http://support.webecs.com/KB/a868/how-do-i-configure-sql-server-express-to-allow-remote.aspx
I use the PDO driver... this works for me:
$db['mssql']['hostname'] = 'sqlsrv:server=myserverIP;database=mydb;encrypt=true;trustservercertificate=true';
$db['mssql']['username'] = 'myun';
$db['mssql']['password'] = 'mypw';
$db['mssql']['database'] = 'mydb';
$db['mssql']['dbdriver'] = 'pdo';
$db['mssql']['dbprefix'] = '';
$db['mssql']['pconnect'] = TRUE;
$db['mssql']['db_debug'] = TRUE;
$db['mssql']['cache_on'] = FALSE;
$db['mssql']['cachedir'] = '';
$db['mssql']['char_set'] = 'utf8';
$db['mssql']['dbcollat'] = 'utf8_general_ci';
$db['mssql']['swap_pre'] = '';
$db['mssql']['autoinit'] = TRUE;
$db['mssql']['stricton'] = FALSE;

codeigniter database error while upload to cpanel

I am trying to upload my codeigniter website to cpanel
But, I am getting following error:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
I have uploaded all my files in directory:
/home/mycpanelusername/public_html/
And,
database name = mycpanelusername_db_databasename
databae username = mycpanelusername_fajs
database password = mydbpassword
and I granted all privileges to my database
My database.php file is like this:
$db['default']['hostname'] = 'http://myurl.org';
$db['default']['username'] = 'mycpanelusername_fajs';
$db['default']['password'] = 'mydbpassword';
$db['default']['database'] = 'mycpanelusername_db_databasename';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
Thank you, If it's not clear please ask me
give $db['default']['hostname'] as ip address
$db['default']['hostname'] ="254.000.0.0";
or
$db['default']['hostname'] = 'localhost';
try like this
Try with localhost like
$db['default']['hostname'] = 'localhost';
May it works and also once check the login credntionals and Db name

CodeIgniter 2.1.2 and MS SQL on PHP 5.3.13

I have been at this one all night and our offices open in 69 minutes.
Our server was just updated to PHP 5.3.13 and a critical online application that connects to MS SQL 2008 is just producing a blank page - no errors being logged, just snow. It is written in CodeIgniter 2.1.2.
If I do not autoload ( or try to connect to the db ), the page displays the static elements. Once I add the database.php config file, it's a white-out.
I am trying the mssql and the sqldrv drivers and getting the same results.
I am hoping to find some ideas on how I can go about debugging this solution in an ASAP sort-of-way.
My offending config (which worked until the upgrade) in the database.php looks like this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "<<SQL SRV NAME>>";
$db['default']['username'] = "<<USERNAME>>";
$db['default']['password'] = "<<PASSWORD>>";
$db['default']['database'] = "<<DATABASE NAME>>";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
ANY thoughts are GREATLY appreciated.
A bit late now I suspect, but the current version of CodeIgniter (2.1.2) has the following in its Database config file by default:
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'database';
$db['default']['dbdriver'] = 'mssql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
Note the extra couple of configs there at the end. It may be looking for them but as they're not supplied it's erroring...

CodeIgniter couldn't connect to database

I have a project working perfectly on my local server (xampp) with:
PHP 5.3.8
MYSQL 5.5.16
APACHE 2.2.21
Now, i try to make it work on the web server and CodeIgniter couldn't connect to database.
I try to connect with this code and works ok:
$link = mysql_connect('localhost', 'user', 'pass');
if (!$link) {
die('No pudo conectarse: ' . mysql_error());
}
echo 'Conectado satisfactoriamente';
but CI says:
Unable to connect to your database server using the provided settings.
The settings on CI database config file are:
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'user';
$db['default']['password'] = 'pass';
$db['default']['database'] = 'database';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
here, you can see working the basic MySQL connection and the phpinfo()
http://guatrache.gov.ar/test.php
and here, you can see the error message from CI:
http://guatrache.gov.ar/index.php
Thanks for your time.
PD: The web server has: PHP 5.3.9, MYSQL 5.1.60
You can autoload the database class, and use active records in your controller. http://codeigniter.com/user_guide/database/active_record.html

Resources