Jump to content

mysqli_stmt::bind_param error message


Go to solution Solved by Barand,

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/317123-mysqli_stmtbind_param-error-message/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.