yccteam
yccteam

Reputation: 2311

Mysqli - prepare fails for no apparent reason

Here's my code:

$mysqli = mysqli_connect('localhost',DB_USER,DB_PASSWORD,DB_NAME);
$mysqli->set_charset("utf8");

$STH = $mysqli->prepare("INSERT INTO wp_kfar_categories_matching (inMate, outMate, categoryId, agesId) VALUES (?, ?, ?, ?)");

    echo $mysqli->error;

    $STH->bindParam("iiii", $in, $out, $categoryId, $agesId);
    echo $mysqli->error;
    $i = 0;
    $length = count($inserts);
    while($i < $length) {
        $in = $inserts[$i]->in;
        $out = $inserts[$i]->out;
        $categoryId = $inserts[$i]->categoryId;
        $agesId = $inserts[$i]->agesId;

            $STH->execute();
            $i++;
    }

The output is: Fatal error: Call to undefined method mysqli_stmt::bindParam() in .../data.php in line 252

I double checked everything I've read so far - the number of arguments is 4, the names of the fields is correct - but no matter what, it doesn't work.

Any idea why this happens?

Upvotes: 0

Views: 45

Answers (1)

Shahar
Shahar

Reputation: 1677

The method is bind_param, so you'd do:

$STH->bind_param("iiii", $in, $out, $categoryId, $agesId);

You were thinking of PDO's bindParam.

Upvotes: 1

Related Questions