i have a funktion that is suposed to make it easy to make prepared sql querys
here is the function
function preparedConnection($stmt,$param){
$dbUsername= 'root';
$dbPassword='';
$dbip = 'localhost';
$db = '129393';
$conn = new mysqli($dbip, $dbUsername, $dbPassword, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo $stmt."<br>";
$stmt_db = $conn->prepare($stmt);
echo $param;
$stmt_db->bind_param($param);
$stmt_db->execute();
$stmt_db->close();
$conn->close();
exit();
}
here is how i use it
$stmt = "INSERT INTO task_times (task_id, login_id, title, description,
used_fixed_price_per_hour ,used_discount_percent, used_price_type) VALUES (?, ?, ?, ?, ?, ?, ?)";
$param = "'iissiii', $task_id , $login_id, '$title', '$description', $used_fixed_price_per_hour, $used_discount_percent, $used_price_type";
$db->preparedConnection($stmt,$param);
but i does not accept vaiables that are string eny help?
$paramjust doesn't work. You cannot pass multiple arguments wrapped in a single string..$paraman array and use things like call_user_func_array to call bind_param; or use PDO where you can pass in an array as params