Posts

Showing posts with the label database

500 Internal Server error with codeigniter mysql connection

I was trying out CodeIgniter  today. I found it quite lightweight and easy to get started with. MVC was fine until I came across a strange issue. Every time I tried to connect to the database, I would end up getting the infamous "500 Internal server error". Unfortunately, even after checking through all http logs, I was not able to trace it to anything that could've gone wrong. I had apache, php, mysql installed and configured correctly. Spent about 4 hours trying out different configurations, playing around with the database names, model names, etc, just to realise later that I did not have the php-mysql driver installed! This time I was on an ubuntu machine, so I had to: apt-get install php5-mysql and then although I could see that apt-get had already restarted apache2 for me, I just thought of doing it myself as well, service apache2 restart and there it was. Everything was working the way I wanted it to be. It was a very silly thing to miss out on this one. I have don...

Configuring remote access for couchdb

By default, CouchDb is configured to be access only from a local port, i.e: you can connect to a couchdb instance as long as it is on the same host. Also, it is necessary that the HTTP request be made using the loopback IP address (127.0.0.1). In case you want to be able to access a couchdb instance from an external machine, you need to make some changes to the couchdb configuration. Note that you would need to have superuser access in order to make changes to these files. Usually couchdb will have two configuration (ini) files in /etc/couchdb depending on your installation. Both these files (default.ini and local.ini) can be used to enable remote hosts to access couchdb. The configuration required for this is: [httpd] port = 5984 bind_address = 0.0.0.0 By default the configuration would be: [httpd] port = 5984 bind_address = 127.0.0.1 This means that the Http server is bound only to the loopback IP address, which is why we change it to 0.0.0.0 to make it bind to any IP address. If...

Drupal 6 db_create_table cannot handle primary/unique keys

The Drupal API provides a function called db_create_table which allows you to create a table in your database. If you need to add a table for a module, after the module is installed, then you could use this function in your update hook. The documentation of db_create_table says that it accepts three arguments, an array which will contain the query result, the name of the table and an array containing the schema definition of the table. The schema definition has to be in the structure defined by the Drupal Schema API . What I recently noticed was, that db_create_table does not seem to accept primary/unique keys in the schema definition. It seems like you need to first create a table without any constraints. For this, you'll have to provide db_create_table with an array containing the schema without any key constraints. After doing that, you can use db_add_primary_key in order to create a primary key. Similarly, there is a function to create a unique key constraint - db_add_uniq...

Adding unlisted locations to the HTC Sense Weather app

The HTC Sense Weather app which comes with the HTC Sensation, has a database which has a predefined set of locations for which it can fetch weather data. But the problem with this is that many locations which you might want to check forecasts for might not be available in it's database. For example, I wanted to list forecasts for Siolim, Goa, India, but the weather app did not have this in it's database. Which means that I just would not be able to have weather forecasts for Siolim, Goa on my phone. But then, I also found out that when I'm in Siolim, I was able to get weather forecasts for Siolim. Later, once when I was googling out about this "issue", I came across a few articles which suggested that it was "possible" to add unlisted locations to the weather app database. For this, you would basically have to "root" your phone and then edit the database file to add your desired locations. Android is an operating system based on Linux, which me...