MySQLi用空的vars /值更新

I change the MySQL to MySQLi in my code

BEFORE: mysql (worked fine)

$set = "costAlertVar ='', costAlertSend = ''";
$eintrag = "UPDATE ".$dbprfx."_users SET $set WHERE connection = '$userConnection'";
$eintragen = mysqli_query($eintrag) or die("Error:".mysql_error());;

NOW: mysqli (not working)

$sql = "UPDATE ".$dbprfx."_users SET costAlertVar = ?, costAlertSend = ?  WHERE connection = ?";
$eintrag = $db->prepare( $sql );
$eintrag->bind_param('sss','','',$userConnection);
$eintrag->execute();
$eintrag->close();
  • costAlertSend = datetime field
  • costAlertVar = text field

mysqli::bind_param uses the parameters as references, so you have to pass values that can be used as references (i.e. variables).

$costAlertVar = '';
$costAlertSend = '';
$eintrag->bind_param('sss',$costAlertVar,$costAlertSend,$userConnection);