0
$sql = "UPDATE users SET ? = ? WHERE user_id = ?";
$stmt = $db->prepare($sql);
$stmt->bind_param("ssi", $obj->{'property'}, $obj->{'value'}, $id);

It says "Fatal error: Call to a member function bind_param() on boolean"

$obj->{'property'} and $obj->{'value'} are strings. $id is int.

What I am doing wrong?

darxysaq
  • 681
  • 2
  • 9
  • 12
  • The error says that `$stmt` is a bool, you're likely looking in the wrong place – Benoit Garret Apr 01 '15 at 14:10
  • @Rizier123 the duplicate you linked to has nothing to do with the question, it really should be closed ("can you debug my code" kind of question)/ – Benoit Garret Apr 01 '15 at 14:12
  • 1
    @BenoitGarret Oh for sure it has to do something with this question! OP tries to bind a column name. Now from the dupe: `Table and Column names cannot be replaced by parameters in PDO.` I think this has something to do with the question here – Rizier123 Apr 01 '15 at 14:14
  • 1
    I see your point, just thought the duplicate could be really confusing without additional comments. @darxysaq the `$db->prepare` statement most likely returns false because you're trying to bind a column name, hence the duplicate, you're looking for the error in the wrong place. – Benoit Garret Apr 01 '15 at 14:18

0 Answers0