This question already has an answer here:
As the title suggest, I've tried different set-ups and had several other issues.
$conn = new mysqli("localhost","root","root","site_db");
foreach($webdesigns as $designer){
$whmcs_id = $designer['id'];
$email = $designer['email'];
$portfolio = json_encode($designer['designs'],JSON_FORCE_OBJECT);
$stmt = $conn->prepare("INSERT INTO partners (whmcs_id,email,portfolio) VALUES (?, ? , ?)");
$stmt->bindParam(1, $whmcs_id);
$stmt->bindParam(2, $email);
$stmt->bindParam(3, $portfolio);
echo $stmt->execute();
}
</div>
It's bind_param when working with mysqli.
It's bindParam when working with PDO.
With MySQLi bind_param, you have to set the variable type, 1,2,3 are not variable types.
Check here for variable types: http://php.net/manual/en/mysqli-stmt.bind-param.php#refsect1-mysqli-stmt.bind-param-parameters
$conn = new mysqli("localhost","root","root","site_db");
foreach($webdesigns as $designer){
$whmcs_id = $designer['id'];
$email = $designer['email'];
$portfolio = json_encode($designer['designs'],JSON_FORCE_OBJECT);
if($stmt = $conn->prepare("INSERT INTO partners (whmcs_id,email,portfolio) VALUES (?, ? , ?)")){
$stmt->bind_param("iss", $whmcs_id,$email,$portfolio);
if(!$stmt->execute()){
print_r("Error : $conn->error");
}
} else{
print_r("Error preparing: $conn->error");
}
}