Translation update done using Pootle.
[phpmyadmin/crack.git] / db_create.php
blob9b1959a54eccadc887d36b12ab695520ab99bff1
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
9 * Gets some core libraries
11 require_once './libraries/common.inc.php';
12 $GLOBALS['js_include'][] = 'functions.js';
13 require_once './libraries/mysql_charsets.lib.php';
15 PMA_checkParameters(array('new_db'));
17 /**
18 * Defines the url to return to in case of error in a sql statement
20 $err_url = 'main.php?' . PMA_generate_common_url();
22 /**
23 * Builds and executes the db creation sql query
25 $sql_query = 'CREATE DATABASE ' . PMA_backquote($new_db);
26 if (!empty($db_collation)) {
27 list($db_charset) = explode('_', $db_collation);
28 if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
29 $sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
31 unset($db_charset, $db_collation);
33 $sql_query .= ';';
35 $result = PMA_DBI_try_query($sql_query);
37 if (! $result) {
38 $message = PMA_Message::rawError(PMA_DBI_getError());
39 // avoid displaying the not-created db name in header or navi panel
40 $GLOBALS['db'] = '';
41 $GLOBALS['table'] = '';
42 require_once './libraries/header.inc.php';
43 require_once './main.php';
44 } else {
45 $message = PMA_Message::success(__('Database %1$s has been created.'));
46 $message->addParam($new_db);
47 $GLOBALS['db'] = $new_db;
49 require_once './libraries/header.inc.php';
50 require_once './' . $cfg['DefaultTabDatabase'];