user2987790
user2987790

Reputation: 145

MySQLi update with empty vars/values

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();

Upvotes: 1

Views: 267

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191729

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);

Upvotes: 1

Related Questions