* * Last Modified: 22nd February 2003 * */ error_reporting(0); if (!(include("./modules/header.lib.php"))) { die("
There was an error loading the header module
"); } // The user doesn't have permission to access mysql if ($params["mysql"] != 1) { redirect($scripts["main"] . "?msg=no_per_sql"); } $op = param("op", "POST"); $databases = explode(",", $params["dbname"]); if($link_id = mysql_connect($params["dbhost"], $params["dbuser"], $params["dbpass"]) == FALSE) { // There was an error connecting to MySQL $database["err_msg"] = mysql_error(); $database["err_num"] = mysql_errno(); $database["caption"] = $database["err_caption"]; $data = template($database, $script_dir . "/settings/templates/mysql_err.tpl"); } else { if ($op == "query") { // The user is running a query $db = param("db", "POST"); mysql_select_db($databases[$db]); // Assign some values list($version) = mysql_fetch_row(mysql_query("SELECT VERSION() as version")); $database["version"] = "MySQL " . $version; $database["database"] = $databases[$db]; $database["db"] = $db; $database["sql"] = htmlspecialchars(param("sql", "POST")); // Execute the query $result = mysql_query(param("sql", "POST")); if (empty($result)) { // No result returned, there is was error in the SQL $database["err_msg"] = mysql_error(); $database["err_num"] = mysql_errno(); $database["caption"] = $database["err_caption"]; $data = template($database, $script_dir . "/settings/templates/mysql_err.tpl"); } else if (mysql_num_rows($result) == 0) { // Zero rows where returned, so it must have been a drop or create query $database["result"] = $database["no_data"]; $database["caption"] = $database["res_caption"]; $data = template($database, $script_dir . "/settings/templates/result.tpl"); } else { // Rows where returned so produce a table of the output $header = ""; for ($i=0; $i