Here is a way of handling this query:
First we create a database handle. Most people these days use the object oriented way of doing it, so we will use it here.
$mysqli = new MySQLi('localhost', 'root', '11111', 'CAR_PARKING_SYSTEM');
Then we define the SQL query. The question marks (?) are place holders for where the values will be placed.
$sql = <<< SQL
INSERT INTO `CUSTOMER_VEHICLE` (
`V_License_No`,
`D_License_No`,
`Arrived_Time`,
`Charge`
) VALUES (
?, ?, ?, ?
);
SQL;
In order to fill out the place holders we need to prepare the query. This is called a "prepared statement" (or "stmt" for short).
Prepared statements are sent to the database, which checks it for errors and also optimizes it so that consecutive calls to the execute() method are performed faster. In this case, however, we are mostly just using a prepared statement in order to avoid malicious input from affecting the query.
$stmt = $mysqli->prepare($sql);
if ($stmt === false) {
die('Could not prepare SQL: '.$mysqli->error);
}
Before we can use the prepared statement we have to have some way of putting values into the place holders. We do that by binding some variables to the place holders. In this case we are binding the variables $vLicense, $dLicense, $arrived and $charge to the place holders. The variables names can be anything.
$ok = $stmt->bind_param('sssi', $vLicense, $dLicense, $arrived, $charge);
if ($ok === false) {
die('Could not bind params: '.$stmt->error);
}
Now that we have bound some variables to the place holders we can start setting their values. In this case we are using the filter_input() function to sanitize the input of some variables. The $charge variable is set to one of two values depending on what vehicle type we are dealing with.
$vLicense = filter_input(INPUT_POST, 'V_License_No', FILTER_SANITIZE_STRING);
$dLicense = filter_input(INPUT_POST, 'D_License_No', FILTER_SANITIZE_STRING);
$arrived = date('H:i');
if (isset($_POST['vehicle_type']) && $_POST['vehicle_type'] === 'four_wheel') {
$charge = 50;
} else {
$charge = 400;
}
The values are set and now we can execute the statement. That is done simply by calling the statement's execute() method:
if ($stmt->execute() === false) {
die('Could not execute query: '.$stmt->error);
} else {
echo '<p>Query executed successfully!</p>';
}
$stmt->close();
I encourage you to read about the MySQLi documentation and the filter extension.
The full code can be found here.
$queryvariable is just a string... you are not inserting anything. Also, you cannot call functions inside strings (thedate('H:i')will not work). Further, your code is very insecure. You should never use data, from users, without vetting it first.