I am trying to save data from an HTML form into database
table:
using Prepared Statements method, But I am getting error against line
<blockquote>
Warning: mysqli_stmt_execute() expects exactly 1 parameter, 0 given in
Here is my code:
</blockquote>
dbConnection.php has below data:
Any suggestions to resolve this?
Code:
wordpress
Code:
wp_testdb
Code:
mysqli_stmt_execute();
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 -> connect_error) {
die("connection failed:".$conn-> connect_error);
}
$date = $_POST['date'];
$select_bank = $_POST['select_bank'];
$entry_type = $_POST['entry_type'];
$income_cat = $_POST['income_cat'];
$amount = $_POST['amount'];
$sql = "INSERT INTO wp_testdb (data_one, data_two, data_three, data_four, data_five) VALUES (?, ?, ?, ?, ?);";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt,$sql)) {
echo "SQL Error !!";
} else {
mysqli_stmt_bind_param($stmt, "sssss", $date, $select_bank, $entry_type, $income_cat, $amount);
mysqli_stmt_execute();
}
}
Code:
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "wordpress";
$conn= mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);