Follow the code:
$campo = $_POST['campo'];
$valor = $_POST['valor'];
$id = $_POST['id'];
$mysqli = new mysqli("localhost","root","","tabela");
mysqli_set_charset($mysqli,"utf8");
$consulta = $mysqli -> prepare("UPDATE tabela SET ? = ? WHERE ID = ?");
$consulta -> bind_param("sss",$campo,$valor,$id); <-------
$consulta -> execute();
Error occurs on the line with the arrow, written error:
bind_param () on a non-object
Error must be occurring because the FIELD is with placeholder (?), since I replaced the field in writing and it worked, ie the query is not done with the field with placeholder .
Only the field of my code will depend on which field the client chose to edit in the table.
Unless I do 10 queries (there are 10 fields), and I determine each field in place of the placeholder .
First, does this really happen? And if so, what can I do as good practice for this case?