CodeIgniter Forums
localhost instead of domain - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: localhost instead of domain (/showthread.php?tid=53455)



localhost instead of domain - El Forum - 07-24-2012

[eluser]rcahanap[/eluser]
New to setting up configs for mysql /code igniter.

In the application/config/database.php file, there is a default variable ('hostname') that you can set.

I had mine set like this:
$db['default']['hostname']="biboba.com";

But I was getting errors.

I changed it to this, and it was OK:
$db['default']['localhost'];

Can someone explain what's the difference?

According to the docs:
['hostname'] The hostname of your database server.

But this is not working.

Thank you in advance for your replies.

-Roberto



localhost instead of domain - El Forum - 07-24-2012

[eluser]Aken[/eluser]
The hostname is the host server where the MySQL database is installed. "localhost" is the most common hostname, but is not always the correct value.

http://dev.mysql.com/doc/refman/5.0/en/connecting.html


localhost instead of domain - El Forum - 07-25-2012

[eluser]sith4life[/eluser]
go into /application/config/database.php and edit
Code:
$db['default']['hostname'] = 'localhost'; // this is dependent on your webhost
$db['default']['username'] = 'dbusername';
$db['default']['password'] = 'dbpass';
$db['default']['database'] = 'dbname';// database name that you will be pulling information from
$db['default']['dbdriver'] = 'mysql'; // from here down should be default
$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;
if you edit those settings with the proper values you will be able to connect to the database
Code:
$db[‘default’][‘localhost’];
i'm not sure what you mean by it works because you aren't assigning any value to that index in the db array.


localhost instead of domain - El Forum - 07-25-2012

[eluser]rcahanap[/eluser]
Hello Aken! Thanks for responding.

Let me click on that link and read then.

-Roberto



localhost instead of domain - El Forum - 07-25-2012

[eluser]rcahanap[/eluser]
Hello sith4life!

I meant to say, I had this:
$db['default']['hostname'] = "localhost";

That worked.

The "explanation" of the variables said:
['hostname'] The hostname of your database server.

The hostname is "dblogix.com". But when I tried that, it did not work.

-Roberto



localhost instead of domain - El Forum - 07-25-2012

[eluser]Aken[/eluser]
If it didn't work, then it clearly is not the correct hostname Wink Domain name and MySQL hostname are two different things.


localhost instead of domain - El Forum - 07-26-2012

[eluser]sith4life[/eluser]
yea the docs are assume you understand that you know the difference between a MySQL Hostname and a webhost. "localhost" in your case is synonymous with "dlblogix.com" but CI will look in your root directory for the Database and not find it because it's on a different part of the server. I hope this makes sense.