Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The number of variables must match the number of parameters in the prepared statement

I use following code to bind parameters, but got still the message: The number of variables must match the number of parameters in the prepared statement

if (!isset ($_GET['token']))
{
echo "<p class='passed'>Link passed.</p>";
}
else
{
$stmt = $conn->prepare("UPDATE database SET is_verified = ? WHERE token = ?");
$status = 1;
$stmt->bind_param("s", $token);
$stmt->bind_param("i",$status);
$res = $stmt->execute();
if ($res)
{
echo "<p class='NewsStat'>You confirmed.</p>";
}
}

The $token value contains 100 characters.
Many thanks in advance!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are not binding params correctly in your code.

if (!isset ($_GET['token']))
{
    echo "<p class='passed'>Link passed.</p>";
}
else
{
    $stmt = $conn->prepare("UPDATE database SET is_verified = ? WHERE token = ?");
    $status = 1;
    $stmt->bind_param("ss", $status, $token);
    $res = $stmt->execute();
    
    if ($res)
    {
        echo "<p class='NewsStat'>You confirmed.</p>";
    }
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading