Warning received:
Warning: mysqli::query(): Empty query in C:\wamp\www\otp-task\welcome.php on line 62
My database connection is here:
function insertDB($email, $OTP , $phonenumber )
{
$servername = "localhost";
$username = "root";
$password = "";
$db = "dbotp";
$conn = new mysqli($servername, $username, $password, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// insert to db and close the connection, default time attribute is 60 mins
// the table name is onetime and will hold the otp and phonenum and email
$res = mysqli_query($conn, "INSERT INTO onetime (otpnum,email,phoneNum,action) VALUES ('$OTP' , '$email' , '$phonenumber','success')");
// $res = "INSERT INTO onetime (otpnum,email,phoneNum,action) VALUES ('$OTP' , '$email' , '$phonenumber', 'success')";
if ($conn->query($res) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $res . "<br>" . $conn->error;
}
$conn->close();
}