MySQLi用空的vars /值更新

时间:2013-12-05 15:58:36

标签: php mysql mysqli sql-update

我在我的代码中将MySQL更改为MySQLi

BEFORE:mysql(工作正常)

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

现在:mysqli(不工作)

$sql = "UPDATE ".$dbprfx."_users SET costAlertVar = ?, costAlertSend = ?  WHERE connection = ?";
$eintrag = $db->prepare( $sql );
$eintrag->bind_param('sss','','',$userConnection);
$eintrag->execute();
$eintrag->close();
  • costAlertSend =日期时间字段
  • costAlertVar =文字字段

1 个答案:

答案 0 :(得分:1)

mysqli::bind_param使用参数作为引用,因此您必须传递可用作引用的值(即变量)。

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