Erwin007 Posted July 25, 2023 Share Posted July 25, 2023 Instead of the $from = $_GET['from'] ?? ''; I have this: <?php $from = "2023-06-15"; //$_GET['from'] ?? ''; $to = $_GET['to'] ?? ''; $tdata = ""; if (!empty($from) && !empty($to)) { $query = " SELECT products.product_name, sum(inventory.inventory_amount) as amount FROM `inventory` JOIN products on products.product_id = inventory.inventory_productid WHERE inventory.inventory_date BETWEEN '$from' AND '$to' GROUP BY products.product_name"; $result = mysqli_prepare($con,$query); $result->bind_param('ss', $from, $to); $result->execute(); $result->bind_result($product_name, $amount); The result is correct but I have an error-message: PHP Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in /home/xxxxxx/public_html/ticketapp/inv_rep.php on line 88 Line 88: $result->bind_param('ss', $from, $to); The problem is obviously the $from = "2023-06-15" instead of $_GET['from'] ?? ''; but how to solve this? Thanks. Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted July 25, 2023 Solution Share Posted July 25, 2023 You are executing a query passing two bound parameter values, but your query has no placeholders for those parameters. Quote Link to comment Share on other sites More sharing options...
Erwin007 Posted July 25, 2023 Author Share Posted July 25, 2023 Instead of WHERE inventory.inventory_date BETWEEN '$from' AND '$to' I did: WHERE inventory.inventory_date BETWEEN ? AND ? and that works correct. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.