how to connect multiple server problem |
[eluser]akioshin[/eluser]
please guys check my code i really need your response this is my database.php Code: $server1['hostname'] = "localhost"; and i get this error Quote:An Error Was Encountered but if i change my database.php to this Code: $active_group = "server1"; and this error appear Quote:A Database Error Occurred this is my controller class Code: class Testing_Controller extends Controller and my model class Code: class Testing_Model extends Model
[eluser]jedd[/eluser]
Two suggestions. First, are you autoloading the database class (config/autoload.php) - because you're not loading it in the code you've shown. Second, you have successfully connected from the CLI? Code: $ mysql -u akioshin -p bmds
[eluser]JayTee[/eluser]
[quote author="akioshin" date="1236152789"]but if i change my database.php to this Code: $active_group = "server1"; Not to nitpick - you're setting the same variable name to two different values; the end result being that the active DB connection is server2; have you verified that you can connect to the server2 settings reliably? You may also want to reconsider your db loading style. You're passing a variable and not using the default "$this" variable to reference CI. http://www.ci.localhost/user_guide/datab...cting.html
[eluser]akioshin[/eluser]
yes im sure that i can connect to server2 i can, sir jaytee what do you mean about db loading style?
[eluser]jedd[/eluser]
When you say 'I'm sure' - do you mean that 'yes, i've tested this manually, including writing to the DB as my code is doing inserts rather than selects and that's a higher privelege requirement than just connecting', or do you mean 'I'm confident'? Also, why (in your config) is the hostname for server2 a URL, and not, well, say, you know .. a hostname?
[eluser]JayTee[/eluser]
[quote author="akioshin" date="1236164215"]yes im sure that i can connect to server2 i can, sir jaytee what do you mean about db loading style?[/quote] If you look in the documentation, the method for loading a db connection is: Code: $this->load->database('name_of_connection') Code: function test() Code: function test()
[eluser]akioshin[/eluser]
thanks anyway boss its now working, after trying with only one server it works and when i put the second server got the error again,and the answer is that i must first grant both servers,and now its working thanks guys |
Welcome Guest, Not a member yet? Register Sign In |