Brian
Brian

Reputation: 294

MySQLi UPDATE isn't working.

For some reason I can't get UPDATE to work, after hours of googling I can't seem to find a working code.

$stmt = $con->prepare("UPDATE user_settings SET accept_emails = ? WHERE user= '$user'");
$stmt->bind_param('s', '0');
$stmt->execute(); 
$stmt->close();

Trying to update via Ajax, keeps returning 500 Server Error. Should I just use the old MySQL way?

Upvotes: 0

Views: 69

Answers (1)

Poorya Mohammadi
Poorya Mohammadi

Reputation: 751

i am pretty sure you can't use a literal in bind only variables. This is what you should use.

$var="0";

$stmt = $con->prepare("UPDATE user_settings SET accept_emails = ? WHERE user=?");
$stmt->bind_param('ss',$var,$user);
$stmt->execute(); 
$stmt->close();

Upvotes: 1

Related Questions