PHP 8.2 MySQLi "The number of variables must match the number of parameters in the prepared statement"

0

Hi,

On our new PHP 8.2 Elastic Beanstalk environment (running platform v4.1.0, PHP 8.2.15) we're getting some intermittent MySQLi "The number of variables must match the number of parameters in the prepared statement" errors.

Note that this fails at the call to "execute()" - not at the call to bind_param()!

This is happening on statements that have never errored in the PHP 7.4 environment, and even with the same parameter values only error in this way periodically (for example, one particular statement was failing 50% of the time, another has failed once in hundreds of calls).

For example (again please note it fails on the execute(), not on the bind_param():

        $stmt1 = $dbConn->prepare("DELETE FROM `some_table` 
        	WHERE ( `active` = 'N' AND `date` < ? )
        	OR ( `date` < ? )
        	LIMIT ?");
        $stmt1->bind_param('ssi', $inactiveThreshold, $thresholdDate, $deleteLimit);
        $stmt1->execute(); // fails here.
        $stmt1->close();

Has anyone else been experiencing this issue?

Thanks, Iain

Iainb
질문됨 2달 전138회 조회
1개 답변
0

Check that the PHP MySQLi extension is installed and enabled. On Elastic Beanstalk, extensions are configured through .ebextensions files.

Verify the number of parameters matches in your prepared statements. Double check your SQL and parameter binding.

Increase error reporting in your PHP configuration to get more details on the errors. You can set display_errors to On and adjust error_reporting levels.

Review your application logs and CloudWatch metrics for any spikes in memory or CPU usage around the error occurrences. Insufficient resources could cause intermittent issues.

Try simplifying the statement and parameters to isolate whether it's related to complexity. Rule out any potential quote or special character issues.

As a test, hardcode the parameter values in the statement instead of binding to check if the error still happens.

profile picture
전문가
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠