无法将值插入数据库表[重复]

$a = "INSERT INTO `uc_messages` (from, to, time, subject, description) VALUES ('q', 'a', CURRENT_DATE(), 'a', 'a')";
$con = mysqli_connect('localhost', '', '');

if(!mysqli_query($con, $a)) { die('Invalid query: ' . mysqli_error($con)); } 

This is the code I'm using to insert values into my table, but for some reason this code doesn't work. This is my database and this is the table I'm trying to insert values into. This is the error I get "Invalid query: No database selected" although I include the file that includes the database.

<?php

//Database Information
$db_host = "localhost"; //Host address (most likely localhost)
$db_name = "users"; //Name of Database
$db_user = "root"; //Name of database user
$db_pass = ""; //Password for database user
$db_table_prefix = "uc_";

GLOBAL $errors;
GLOBAL $successes;

$errors = array();
$successes = array();

/* Create a new mysqli object with database connection parameters */
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
GLOBAL $mysqli;

if(mysqli_connect_errno()) {
    echo "Connection Failed: " . mysqli_connect_errno();
    exit();
}

//Direct to install directory, if it exists
if(is_dir("install/"))
{
    header("Location: install/");
    die();

}

?>
</div>

Can you try next code and let us know what is the output?

// database connection, update user, password and database
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    exit;
}

// insert data
$query = "INSERT INTO `uc_messages` (`from`, `to`, `time`, `subject`, `description`) VALUES ('q', 'a', CURRENT_DATE(), 'a', 'a')";
if(!mysqli_query($query)) {
    echo 'Invalid query: ' . mysqli_error($mysqli);
    exit;
} 

echo 'Success';

One of the issues is an invalid mix of interface function calls. The code shown uses mysqli_ function for making the connection to the database. With that, use the mysqli_ functions, do not use the (old, long deprecated and now removed in PHP7) mysql_ functions.

After replacing the (invalid) mysql_query function with an appropriate mysqli_ function, check the return from the function. If the return is FALSE, use the appropriate function (mysqli_error) to retrieve the MySQL error message.

What was the question?