I have a controller that does uploading to the host server and another controller that does uploading to youtube. After the former controller does its job, it redirects to the latter. After a particularly long uploading process which involves youtube, I was getting "MySQL server has gone away" errors 

I used this code to reconnect to database in Codeigniter to solve that problem.

```
$this->db->reconnect();

```

Instead I got an error

```
A Database Error Occurred
Unable to select the specified database: test_database
....

```

I tried adding this code before and after the "reconnect" code but it did not help('test' below is the name of the active group in the database config I am using.)

```
$this->load->database('test');

```

Anyone have an idea how to solve this?