I have a problem with an extension I’m using. It’s a slightly modified “Registration Codes” extension, and the issue is that, during the hook “member_update_end”, I have a validation function that makes a call to an unrelated internal database.
At first I was getting strange errors that told me nothing, then I played around with things a little, and it appears that my connection to the other database is disconnecting the Expression Engine db connection.
Basically, when the validation fails, I end the function like so:
if (!$match)
{
$this->extensions->end_script = TRUE;
$error = array($this->EE->lang->line('rogee_rc_no_valid_code'));
return $this->EE->output->show_user_error('submission', $error);
}
Now, the error I’m getting at this point is:
A Database Error Occurred
Error Number: 1146
Table ‘other_database.exp_specialty_templates’ doesn’t exist
SELECT `template_data` FROM (`exp_specialty_templates`) WHERE `site_id` = ‘1’ AND `template_name` = ‘message_template’
Filename: core/EE_Output.php
Line Number: 314
Note, that “other_database” is the name of the database that I do a quick connection to, during the validation function. In other words, it seems that EE is losing its internal database connection, and for some reason proceeding to try and connect to my internal database. (My internal database connection, in my function, looks like this:
$connect = mysql_connect('localhost','USER','PASS');
if (!$connect) {
die('Could not connect to MySQL: ' . mysql_error());
}
$cid = mysql_select_db('subscriptions',$connect);
$sql = "SELECT * FROM active_subscriptions WHERE subscription_number LIKE '%".$submitted_code."%'";
$result = mysql_query($sql, $connect);
$num_rows = mysql_num_rows($result);
mysql_close($connect);So I thought, maybe there’s a database setting.. and I found “Persistent Database Connection” in the backend Administration > Database Settings. So I thought, great, this will likely fix it.. then I tried to change this setting, and get this error message:
Fatal error: Call to undefined function read_file() in /home/council/public_html/system/expressionengine/core/EE_Config.php on line 1122
So I’m stumped. I can’t find anything online. Any ideas?