Mysqli_stmt:execute() error

here’s my website:

I have successfully connected to my database but I was having a problem in fixing this part of the code:

Error Message

Warning : mysqli_stmt::execute() expects exactly 0 parameters, 1 given in /home/vol14_1/ on line 63
ERROR: There was a problem while saving the data.

What is your code on line 63?


I checked your code and see that line 63 contains the following code (actual variable names removed):

$result = $stmtinsert->execute([....]);

At first sight, this is OK. After all, the PHP docs say that you can pass params this way.

However, if you read the documentation more closely, you see that this option was only added with PHP 8.1.0. The latest version of PHP we have is PHP 7.4, which doesn’t have this function parameter.

So instead, you need to use the bind_param() function to bind the parameters to the statement, and then call execute() without any arguments.

So, as taken from the documentation:

$stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)");
$stmt->bind_param('sssd', $code, $language, $official, $percent);

Alright got it, and it works now. Thank you!

Also I wanna know what ‘sssd’ represents? is it like s for string?


Yes! Here’s the rest from the official php docs:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.