CodeIgniter Forums
i can`t connect to database if i use 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: i can`t connect to database if i use domain (/showthread.php?tid=28317)



i can`t connect to database if i use domain - El Forum - 03-08-2010

[eluser]minhbu[/eluser]
i have a hosting and domain.I uploaded a website to hosting.
If i access by hosting link,it connect to database success, but when i use type domain name.
exame http://subdomain.domain.com is website connect to database success
but if i type http://subdomain.domain.com/news is i get a error Unable to connect to your database server using the provided settings.

file database
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "mywebsite";

how do i type http://subdomain.domain.com/news is website connect to database success ???


i can`t connect to database if i use domain - El Forum - 03-08-2010

[eluser]xeroblast[/eluser]
bcoz your host is incorrect...

if you are using a DSN then you shoukld write it this way...

Quote:dbdriver://username:password@hostname/database



i can`t connect to database if i use domain - El Forum - 03-08-2010

[eluser]minhbu[/eluser]
where do i type above link ??
who have other way???


i can`t connect to database if i use domain - El Forum - 03-08-2010

[eluser]xeroblast[/eluser]
$this->load->database('dbdriver://username:password@hostname/database');

or check the http://ellislab.com/codeigniter/user-guide/database/connecting.html