Welcome Guest, Not a member yet? Register   Sign In
Unable to connect to the DB - CI 2
#11

[eluser]Nicholas Hanks[/eluser]
Can you try same with latest PHP 5.3.3. Please let me know the result.
#12

[eluser]InsiteFX[/eluser]
I just checked this on PHP.net and it is a bug, but not in PHP.
The bug seems to me in the MySQL libraries.
On Windows Vista and Windows 7.

Strange that it works on my PHP 5.3.1

To fix you have to use 127.0.0.1

InsiteFX
#13

[eluser]Nicholas Hanks[/eluser]
Yeah that was my fix too. Thanks for looking around.
#14

[eluser]InsiteFX[/eluser]
c:\Windows\System32\drivers\etc

Your path may be different.

Open HOSTS with notepad

If it has a # sign in front of it remove the # sign.
#127.0.0.1 localhost

Should be:
127.0.0.1 localhost

InsiteFX
#15

[eluser]ci92037[/eluser]
I have the same problem.

I have CodeIgniter 1.7.2 installed on OS X 10.6.5, with MySQL 5.1.51 and PHP 5.3.3.

I got the error, "Unable to connect to your database server using the provided settings."

In config/database.php I changed $db['default']['hostname'] from "localhost" to "127.0.0.1" and the error went away and now the site works.

FWIW.
#16

[eluser]DominixZ[/eluser]
I have unable to connect to the DB too in CodeIgniter 2 [Download from Repo at Nov 24]
but I cannot connect to the DB only from commandline


In commandline use like this
Code:
php cli.php "welcome/index"

and it happen like this

Code:
<div id="content">
        <h1>A Database Error Occurred</h1>
        <p>Unable to connect to your database server using the provided settings.</p><p>Filename: /Users/dominixz/Sites/onebitframework/controllers/welcome.php</p><p>Line Number: 19</p>    </div>

but If I open with browser no error.

cli.php I use from NetTuts this is code
Code:
#!/usr/bin/php
&lt;?php
if (isset($_SERVER['REMOTE_ADDR'])) {
    die('Command Line Only!');
}

set_time_limit(0);

$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = $argv[1];

require dirname(__FILE__) . '/index.php';

This is work fine in CI 1.7.2

and I have another question CI 2.0 autoload "database" doesn't show error like CI1.7.2 isn't it ? because in CI 1.7.2 if i enter wrong username or password or database and i'm autoload it it will unable to connect instantly but in CI2.0 doesn't i must use some $this->db->get() and then it will be show error.

My Question is "Is it change behavior of this ? or it only me that have something like this ?"

Thank in advance
#17

[eluser]InsiteFX[/eluser]
Also try this:
Code:
$db['default']['pconnect'] = FALSE;

InsiteFX
#18

[eluser]DominixZ[/eluser]
Still got the same
#19

[eluser]selinan[/eluser]
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
try to enter a password, this edition i hadn't used, i used the old one.
#20

[eluser]bloodylyons[/eluser]
I've just got hold of 1.7.3 on my iMac running OS 10.6.4 & PHP 5.3.2 and could not connect to my local DB
with 'localhost' as the hostname. Works fine on my macbook running MAMP though.

Just changed hostname to 127.0.0.1 and it works fine now.

cheers




Theme © iAndrew 2016 - Forum software by © MyBB