I'm unfortunately getting an empty query warning and i cant seem to find the issue I hope you'll help me.
mysqli->query( ) --> $result = $conn->query($sql); is where it tells me i'm doing something wrong.
<?php
global $wpdb;
if ( isset( $_POST['submit'] ) ){
$servername = "localhost";
$username = "root";
$password = "****";
$dbname = "***";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$user = $current_user->ID;
$time = new DateTime('now');
$reg_id = $wpdb->escape(trim($_POST['reg_id']));
$dato = $wpdb->escape(trim($_POST['$time']));
$fiske_vægt = $wpdb->escape(trim($_POST['fiske_vægt']));
$fiske_længde = $wpdb->escape(trim($_POST['fiske_længde']));
$reg_user_id = $wpdb->escape(trim($_POST['$user']));
$sql = $wpdb->insert( 'wp_registreringer',
array(
'dato' => apply_filters('pre_register_dato', $dato),
'fiske_vægt' => apply_filters('pre_register_fiske_vægt', $fiske_vægt),
'fiske_længde' => apply_filters('pre_register_fiske_længde', $fiske_længde),
'reg_user_id' => apply_filters('pre_register_reg_user_id', $user)
)
);
$result = $conn->query($sql);
My form
<form method="post">
<h3>Don't have an account?<br /> Create one now.</h3>
<p><label>længden</label></p>
<p><input type="number" value="" name="fiske_længde" id="fiske_længde" />cm</p>
<p><label>vægten</label></p>
<p><input type="number" value="" name="fiske_vægt" id="fiske_vægt" />kg</p>
<p><label>dato</label></p>
<p><input type="datetime-local" name="dato" value="<?php echo date("Y-m-d\TH:i:s",time()); ?>"/></p>
<button type="submit" name="btnregister" class="button" >Submit</button>
<input type="hidden" name="submit" value="submit" />
</form>