![]() |
Database Connection Accross a Network - 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: Database Connection Accross a Network (/showthread.php?tid=6857) |
Database Connection Accross a Network - El Forum - 03-14-2008 [eluser]polaris1927[/eluser] I have a web server box and a database server box; connection attempts to the database server from the web server generates the error message: Code: An Error Was Encountered It works when both web and database apps are sitting on the same server box and if I attempt to connect outside of the CI framework. Is there a config setting for network access that I am missing? Database Connection Accross a Network - El Forum - 03-14-2008 [eluser]polaris1927[/eluser] I had configured the database class in the autoload.php file as follows: Code: $autoload['libraries'] = array('database'); Removing the class from the autoload.php file and attempting to connect to the database from the controller using: Code: function index() worked. So, there seems to be a problem with the autoload.php and the database library? Database Connection Accross a Network - El Forum - 03-14-2008 [eluser]Pygon[/eluser] The only real difference between your code and CI's code is that CI has rawurldecode() for the hostname and such (which shouldn't cause a problem). Ofcourse, this assumes that you have Code: $db['default']['dbdriver'] = "mssql"; or your testing isn't very valid (since CI will try to use a persistent connection, unlike your code). Otherwise, not sure what to say -- works perfectly fine for me using a remote MSSQL database and persistant connections. Database Connection Accross a Network - El Forum - 03-14-2008 [eluser]polaris1927[/eluser] Thanks for the reply. My database config is shown below: Code: $db['test']['hostname'] = "srv03"; Ruled out network connection, since I did successfully conect to the database outside of CI. Database Connection Accross a Network - El Forum - 03-14-2008 [eluser]polaris1927[/eluser] where can I find the code that reads the autoload.php liberies list? Also, "rawurldecode() for the hostname" where is this defined? THX Database Connection Accross a Network - El Forum - 03-14-2008 [eluser]polaris1927[/eluser] Found the solution!! Code: $db['test']['hostname'] = "srv03\phonedirec"; you need to get rid of the double quotes ("") and replace with single quotes (''), so that you now have: Code: $db['test']['hostname'] = 'srv03\phonedirec'; My database was configured as an instance, therefore I included a backslah when defining the ['hostname'] and this created a problem in CI. Database Connection Accross a Network - El Forum - 03-14-2008 [eluser]Pygon[/eluser] Ahh -- yes, I didn't know you were using a "\" (the escape operator). With ""(double-quotes) you should use \\ (two backslashes) to show that you want a backslash to be output. |