So im trying to select the database that is created by my createdb($name) function.
the $name is set on another page that i do not want to access but i need to access the name of createdb($name) so i can select it in my connectdb() function.
[Reformatted code to get rid of all those empty lines. ~ NogDog]
$con;
function connectdb($value)
{
global $con;
if (empty($value) or $value == 'scope') {
include ('D:\wamp\www\willpower\system\config.php');
}
$con = mysqli_connect($hostname, $username, $password) or die('connection failed');
if (!empty($database)) {
mysqli_select_db($con, $database) or die('Fatal Database Error No Database Selected');
}
}
function createdb($name)
{
global $con;
include ('D:\wamp\www\willpower\system\config.php');
if (empty($database)) {
$database = $name;
}
$querycreate = mysqli_query($con, "CREATE DATABASE $name") or die("Fatal Database Error Unable To Create Database $name ");
$escape = mysqli_real_escape_string($con, $querycreate);
}
function createtable($name, $values)
{
global $con, $userdatabase;
$query = "CREATE TABLE $name ($values)";
$querycreate = mysqli_query($con, $query) or die("Fatal Database Error Unable To Create Database Table ");
$escape = mysqli_real_escape_string($con, $querycreate);
}
function queryinto($tablename, $rows, $values)
{
global $con;
$query = "INSERT INTO $tablename ($rows) VALUES ($values)";
if (!empty($con)) {
$querying = mysqli_query($con, $query) or die('Fatal Database Error Query Not Set');
$escaping = mysqli_real_escape_string($con, $querying);
}
}