- $conn = $db_connections[$selected_id];
- if (($db = db_create_db($conn)) == 0)
- {
- display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually"));
- $error = true;
- } else {
- if (!db_import($path_to_root.'/sql/'.get_post('coa'), $conn, $selected_id)) {
- display_error(_('Cannot create new company due to bugs in sql file.'));
+ $db_connections[$selected_id]['name'] = $_POST['name'];
+ if ($new) {
+ $db_connections[$selected_id]['host'] = $_POST['host'];
+ $db_connections[$selected_id]['port'] = $_POST['port'];
+ $db_connections[$selected_id]['dbuser'] = $_POST['dbuser'];
+ $db_connections[$selected_id]['dbpassword'] = html_entity_decode($_POST['dbpassword'], ENT_QUOTES,
+ $_SESSION['language']->encoding=='iso-8859-2' ? 'ISO-8859-1' : $_SESSION['language']->encoding);
+ $db_connections[$selected_id]['dbname'] = $_POST['dbname'];
+ $db_connections[$selected_id]['collation'] = $_POST['collation'];
+ if (is_numeric($_POST['tbpref']))
+ {
+ $db_connections[$selected_id]['tbpref'] = $_POST['tbpref'] == 1 ?
+ $tb_pref_counter."_" : '';
+ }
+ else if ($_POST['tbpref'] != "")
+ $db_connections[$selected_id]['tbpref'] = $_POST['tbpref'];
+ else
+ $db_connections[$selected_id]['tbpref'] = "";
+
+ $conn = $db_connections[$selected_id];
+ if (($db = db_create_db($conn)) === false)
+ {
+ display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually"));