mysqli_stmt_execute() expects exactly 1 parameter, 0 given

admin

Administrator
Staff member
I am trying to save data from an HTML form into database
Code:
wordpress
table:
Code:
wp_testdb
using Prepared Statements method, But I am getting error against line
Code:
mysqli_stmt_execute();
<blockquote>
Warning: mysqli_stmt_execute() expects exactly 1 parameter, 0 given in
Here is my code:
</blockquote>
Code:
if(isset($_POST['BtnSubmit'])){
    include_once 'dbConnection.php';

    if($conn -&gt; connect_error) {
        die(&quot;connection failed:&quot;.$conn-&gt; connect_error);
    }
    
    $date           = $_POST['date'];   
    $select_bank    = $_POST['select_bank'];
    $entry_type     = $_POST['entry_type'];
    $income_cat     = $_POST['income_cat'];
    $amount         = $_POST['amount'];
        

    $sql = &quot;INSERT INTO wp_testdb (data_one, data_two, data_three, data_four, data_five) VALUES (?, ?, ?, ?, ?);&quot;;
        
    $stmt = mysqli_stmt_init($conn);
        
    if (!mysqli_stmt_prepare($stmt,$sql)) {
            echo &quot;SQL Error !!&quot;;
    } else {
        mysqli_stmt_bind_param($stmt, &quot;sssss&quot;, $date, $select_bank, $entry_type, $income_cat, $amount);
        mysqli_stmt_execute();
    }
}
dbConnection.php has below data:
Code:
&lt;?php

$dbServername = &quot;localhost&quot;;    
$dbUsername = &quot;root&quot;;
$dbPassword = &quot;&quot;;
$dbName = &quot;wordpress&quot;;
    
$conn= mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
Any suggestions to resolve this?