Having trouble generating feedback
Posted: Mon Sep 21, 2009 11:02 am
I made a script that creates a new database in mysql.
It creates the database just fine. However, it will not deliver the feedback that the data was created. Where did I go wrong? Thanks in advanced.
Here is the code for the index file.
Here is the code for the database generator
Here is the code for the output file
It creates the database just fine. However, it will not deliver the feedback that the data was created. Where did I go wrong? Thanks in advanced.
Here is the code for the index file.
Code: Select all
<?php
if (!isset($_REQUEST['database']))
{
include 'form.html.php';
}
else
{
$database = $_REQUEST['database'];
$database = str_replace(" ","",$database);
$database = strtolower($database);
$output= htmlspecialchars($database, ENT_QUOTES, 'UTF-8');
include 'dbgenerator.php';
}
?>
Code: Select all
<?php
$link = mysqli_connect('localhost', 'root', '**********');
if (!$link)
{
$output = 'Unable to connect to the database server.';
include 'output.html.php';
exit();
}
$sql = 'CREATE DATABASE ' . $database;
mysqli_query($link, $sql);
if (!mysqli_query($link, $sql))
{
$output = 'Error creating ' . $database . ' database.';
exit();
}
else
{
$output = $database . " successfully created.";
include 'output.html.php';
}
?>
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Output</title>
<meta http-equiv="content-type"
content="text/html; charset=utf-8"/>
</head>
<body>
<p>
<?php
echo $output;
?>
</p>
</body>
</html>