I am a beginner in PHP and am getting this error when trying to do an insert in the database using Mysqli functions:
Fatal error: Call to a member function bind_param() on string in C:\xampp\htdocs\Uc16\cadastro.php on line 5
What am I doing wrong?
$sql = "INSERT INTO tb_usuarios(user_nome,user_senha,user_nivel,user_cpf,user_end_rua,user_end_bairro,user_end_numero,user_tel,user_email) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
$sql->bind_param('ssisssiss',
$_POST['user_nome'],
$_POST['user_senha'],
$_POST['user_nivel'],
$_POST['user_cpf'],
$_POST['user_end_rua'],
$_POST['user_end_bairro'],
$_POST['user_end_numero'],
$_POST['user_tel'],
$_POST['user_email']);
if ($conn->query($sql) === TRUE) {
echo "Registrado";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>