2
Follows 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 line with the phlegm, error in writing:
Call to a Member Function bind_param() on a non-object
Error must be occurring due to the FIELD is with placeholder(?), for I replaced the Field in writing and it worked, ie query is not made 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 turn 10 darlings (are 10 fields), and determine each field in place of the placeholder.
First, does this really occur? And if so, what can I do as good practice, for this case?
Ah, yes, all POSTS are successfully received, the same error, that for me is new, is to know that I can not use placeholder (character of the Prepared statements) in the field(SET = ?(field)).. As I said, I replace the placeholder(?) with the field name(SET = Street(field)) and it worked, but in my case it wouldn’t work, since the Field can be 10, it depends on what the customer chooses to update!..
– Ale